Skip to content

bisync: fix handling of Google Docs #5696

Closed

Description

@ivandeex

Snippet from cjnaz/rclonesync-V2#1

The problem comes up if we attempt to upload a modified exported document, with the same name,
back to Google Drive: "Failed to copy: can't update a google document". Similarly, deleting the
local copy and then rclone syncing local to Drive: results in "Couldn't delete: can't delete a google
document".

Proposed behavior:

A new --export-google-docs switch will export (copy to Local) every found Google document as
_export.. The final rclone sync will put a copy of the exported document on Google
Drive as well. The date-stamp on the file will match the original Google document.

Later, with --export-google-docs, If the native Google document timestamp is newer, and the
existing exported file is unchanged (relative to the prior sync), then the document will
be exported again, replacing the current _export file.

If the exported file is changed (newer) then it will be synchronized as usual/normal, but the
native Google document cannot be updated. Effectively, the file version and the native version
are out of sync.

If the exported file had previously been changed, and now the native Google document is changed,
then --export-google-docs will blast/replace the file version. User beware. There is no reliable
way to detect that the file version and the native Google document version have both been
modified. The user is advised to rename the modified file version if he/she plans to subsequently
edit the native Google document via the web interface.

If --export-google-docs switch is not set then all Google document files (as indicated by
file size -1) will be ignored. Previously exported documents (which are now regular files)
will be synchronized as usual.

Other comments

As @ncw noted at #5164 (comment)
we should probably consider other things with size < 0 (eg Google Photos) which will have that too.

As @cjnaz noted in his commit review, the log message Ignoring incorrect line: "- -1 - - ... GoogleDoc.docx is rather vague and should be improved. The commented dump from bisync.md was:

2021/05/11 08:23:15 INFO  : Synching Path1 "/path/to/local/tree/base/" with Path2 "GDrive:"
2021/05/11 08:23:15 INFO  : ...path2.lst-new: Ignoring incorrect line: "- -1 - - 2018-07-29T08:49:30.136000000+0000 GoogleDoc.docx"
2021/05/11 08:23:15 INFO  : Bisync successful

References

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. self-assigned this
    on Oct 8, 2021
  2. ivandeex commented on Mar 29, 2022

    @ivandeex
    MemberAuthor

    Related problem report:
    https://forum.rclone.org/t/bisync-of-googledocs-on-googledrive/29961/2

    I'm trying to use bisync with Googledocs on googledrive and --drive-import-formats --drive-export-formats to do a 2 way conversion between MS formats on local and Googledoc formats on Googledrive

    However this doesn't seem to work, with rclone getting confused with file extensions etc. An initial --resync works in either directions if you start with either local or google drive populated but any subsequent bisync without --resync fails

  3. ivandeex commented on Apr 15, 2022

    @ivandeex
    MemberAuthor

    Probably related issue reported on forum

    https://forum.rclone.org/t/is-bisync-ready-for-prime-time/30109/9

    Actually it did delete files
    rclone bisync -iv --resync gdrive:Finance /HaackTrustGDrive/Finance --exclude '*'
    rclone: delete "RRH/2022-01-18 telecon notes.docx"

  4. changed the title [-]bisync: improve handling of Google Docs[/-] [+]bisync: fix handling of Google Docs[/+] on Apr 15, 2022
  5. nielash commented on Aug 20, 2023

    @nielash
    Contributor

    The problem comes up if we attempt to upload a modified exported document, with the same name,
    back to Google Drive: "Failed to copy: can't update a google document". Similarly, deleting the
    local copy and then rclone syncing local to Drive: results in "Couldn't delete: can't delete a google
    document".

    This appears to no longer be true. It looks like the quoted comment is from 2018, and a few months later Rclone greatly improved its handling of Google Docs, but the Bisync code was never updated to reflect this new reality (even despite being translated in 2021, after these changes).

    So, it looks to me like all we really need to do here is remove the code that was added to detect and skip Google Docs, and just let Rclone handle them the same way it would for sync. (A quick test on my end seems to confirm this, but I want to test further and just make sure I'm not missing something.)

    That said, I will still personally be keeping --drive-skip-gdocs on all my Bisync runs, as I'm not keen to have my Google Docs overwritten by local .docx versions, nor do I want my actual .docx files converted to Google Docs. But it should be supportable for people who do 😃

    Also, when we fix #5683 and #5684 we'll have to handle this case with special care... Google Docs always have a size of -1 and no checksum, so it will always look like a mismatch with the opposite path, if we're only comparing the listing strings. But until then it shouldn't matter, as comparing the modtime should still work.

  6. self-assigned this
    on Sep 5, 2023
  7. added this to the Soon milestone on Sep 5, 2023
  8. Rixtho commented on Oct 31, 2023

    @Rixtho

    Just wanted to ask whether there is any active development on this issue?

    Also a bit unrelated… If I understood correctly it is already possible to convert Google Doc files to links. But this still creates a syncing issue as rclone then also copies those links to Google Drive. I would prefer if links to Google Docs would not be also synced to Google Drive since these links are unnecessary duplicates when accessing my drive from Windows or my phone.

    Also I think it is possible via Chrome's API to download all Google Doc files into web storage. If you edit files there Chrome should automatically take care of synchronization. So only thing rclone would have to do is convert Google Docs into links that open that specific file from web storage. I think this would be a more elegant solution than converting Google Docs into completely different formats.

  9. nielash commented on Oct 31, 2023

    @nielash
    Contributor

    @Rixtho I actually have a fix ready to go, but have been sitting on it until I have a chance to test it more thoroughly (which I haven't done yet because I've been focusing on a few higher-priority tickets.) Would you be interested in helping to beta-test it and give feedback?

    Also a bit unrelated… If I understood correctly it is already possible to convert Google Doc files to links. But this still creates a syncing issue as rclone then also copies those links to Google Drive.

    I think you're referring to the --drive-export-formats=url option, right? If so, I think for the most part this should already work how you want it to, with some important caveats I'll explain below. For example, if you currently run the following:

    rclone sync drive:somefolder local/somefolder --drive-export-formats=url
    rclone sync local/somefolder drive:somefolder --drive-export-formats=url
    

    the .url files will be created locally during the first command, and not duplicated in drive during the second command (because rclone finds a gdoc with the same name and understands they are the same file). Where you do have to be careful is if you manually create/rename a .url file on the local side, because if you sync with local as the source and then rclone doesn't find a matching gdoc on the drive side, it won't know what you want it to do -- so in that scenario it would copy the literal .url file to drive.

    As far as bisync is concerned, my proposed fix essentially just lifts the current bisync-specific restrictions on google docs and allows rclone to handle them the same way it would in sync. This means that --drive-export-formats=url should also work as expected (just be sure to only create/edit/rename your google docs on the google drive side, because of the above.)

    Also I think it is possible via Chrome's API to download all Google Doc files into web storage. If you edit files there Chrome should automatically take care of synchronization. So only thing rclone would have to do is convert Google Docs into links that open that specific file from web storage. I think this would be a more elegant solution than converting Google Docs into completely different formats.

    That is an interesting idea. Since it affects the drive backend as a whole (not just bisync), I would suggest opening a new issue to request and discuss it further.

  10. Rixtho commented on Nov 1, 2023

    @Rixtho

    @nielash I've never worked on this project before and I'm not an expert on Rclone, so I'm not sure if I'm the best choice. What do you mean by beta testing? Just manually running different scenarios and checking if everything works as expected? If you could provide a rough guide, I might be able to help with the testing.

    As for my other idea, it seems that the URL is already enough to access a file if it was made available offline via Google Drive in Chrome. So the only possible improvement would be if Rclone could take care of making all my Google Workspace files available offline, instead of me having to manually go through all my folders and click "make available offline". A quick Google search didn't turn up any results about whether this is possible via the Google Drive API, but I could open an investigation issue on this.

  11. nielash commented on Nov 9, 2023

    @nielash
    Contributor

    What do you mean by beta testing? Just manually running different scenarios and checking if everything works as expected? If you could provide a rough guide, I might be able to help with the testing.

    Yes, that is basically what I mean! Are you comfortable with installing from source?

  12. 11 remaining items

  13. added 7 commits that reference this issue on Nov 22, 2023
    3558b47
    0198dfb
    49fd1ac
    3055d72
    dcebb06
  14. hideki2k02 commented on Dec 26, 2023

    @hideki2k02

    FYI I have uploaded an early preview here if you are interested in trying it! (There are downloadable binaries if you prefer that to installing from source.)

    Details in the new docs regarding how bisync handles Google Docs.

    Many thanks for that! Been scratching my head for days trying to figure out why my bisync script was not working haha

  15. added a commit that references this issue on Jan 20, 2024
    9cf7836
  16. added a commit that references this issue on Jan 23, 2024
    f70a4c6
  17. moved this to Done in bisyncon Aug 20, 2024
  18. added a commit that references this issue on Jul 20, 2026
    5ba198a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions