Skip to content

WIP: drive: upload documents and document links - #2479

Merged
ncw merged 7 commits into
rclone:masterfrom
B4dM4n:drive_import_formats
Sep 25, 2018
Merged

ncw merged 7 commits into
rclone:masterfrom
B4dM4n:drive_import_formats

Conversation

@B4dM4n

@B4dM4n B4dM4n commented Aug 21, 2018 •

Copy link
Copy Markdown
Collaborator

This has become a bigger change than thought at first.

To address #1349 #2046 and #1065 I rewrote many parts of the drive remote since the current state became to cluttered with all features stacked on top of it.

The two major things rewrote are the mime-type handling and splitting Object into smaller functional types.

The mime-type handling is now done by the mime package which makes use of the system wide mime-types. The basic mime-types that got used before are still registered.

The Object type is now split into 3 types and one baseObject.

  • baseObject is embedded by all other objects and contains the shared fields
  • Object now only represents a generic file without document handling
  • documentObject handles google docs. This still has as Size of -1, which gets updated after read.
  • linkObject contains the new link file handling. Currently implemented are .desktop, .link.html (added .link since .html is a valid export format), .url and .webloc files. I could only test .link.html until now, but will test .desktop and .url soon.

Since this is a big change and not yet complete I don't think we should merge this before the v1.43 release.
@ncw How do you like the split Object design. Are you fine with returning other concrete types besides *Object as fs.Object?

TODO:

  • Add documentation for --drive-import-formats
  • Add documentation for rules of allowed conversions / updates
  • Add documentation for link files
  • Test .url link files on Windows
  • Test .desktop link files on Linux
  • Test .url and .webloc link files on MacOS
  • Test application/vnd.google-apps.script export/import
  • Handle filename changes during sync?

Examples:
By default the conversion to Google Docs is only allowed when the uploaded file gets the same file type (determined by --drive-export-formats) as the source.

To upload .doc files as Google Docs use .doc as export and import format:

rclone copy --drive-import-formats=.doc --drive-export-formats=.doc /folder TestDrive:

To allow upload of multiple file types as Google Docs, --drive-allow-import-name-change has to be used:

rclone copy --drive-import-formats=.doc,.txt --drive-allow-import-name-change /folder TestDrive:

Using the link files works by specifying the link file extension as a --drive-export-formats:

rclone copy --drive-export-formats=.link.html TestDrive: /folder

This also works for mount:

rclone mount --drive-export-formats=.link.html TestDrive: /folder

@ncw

ncw commented Aug 23, 2018

Copy link
Copy Markdown
Member

This has become a bigger change than thought at first.

It did didn't it ;-)

Since this is a big change and not yet complete I don't think we should merge this before the v1.43 release.

That sounds sensible to me.

How do you like the split Object design. Are you fine with returning other concrete types besides *Object as fs.Object?

Absolutely. As long as it satisfies the interface (and any optional interfaces we need on that Object) then I'm fine with that.

I think if the split object design makes the code cleaner then let's go with it. In drive, gdocs and drive objects are quite different things so I think having two object types makes perfect sense.

If you want to push this to a branch on ncw/rclone then the CI will build a beta and we can get other people testing things when you are ready.

I think clear docs are going to be quite important for this feature!

I see this deprecates --drive-formats - will this continue to work as before so we don't break peoples scripts? Do you think at some point we will remove it? Or make it set both import and export formats?

@B4dM4n

B4dM4n commented Aug 23, 2018

Copy link
Copy Markdown
Collaborator Author

Absolutely. As long as it satisfies the interface (and any optional interfaces we need on that Object) then I'm fine with that.

Perfect. I put interface checks at the bottom of drive.go for all types as before.

If you want to push this to a branch on ncw/rclone then the CI will build a beta and we can get other people testing things when you are ready.

I will do that. Just need to make sure people know that the new features (and maybe the whole drive remote) are experimental and can contain serious bugs.

I think clear docs are going to be quite important for this feature!

Definitely. There are many details hidden from the users behind the --drive-*-formats flags. When used without --drive-allow-import-name-change the conversions should work seamless and otherwise produce understandable error messages.

I see this deprecates --drive-formats - will this continue to work as before so we don't break peoples scripts? Do you think at some point we will remove it? Or make it set both import and export formats?

--drive-formats will work as before, even in combination with --drive-import-formats. There is a migration logic that transfers the value from opt.Extensions to opt.ExportExtensions, but only one of the options is allowed to be set.

At some point --drive-formats should be removed. It's name could imply that this is the default value for imports and exports. I will set OptionHideConfigurator in the next push to hide it during configuration.

--drive-import-formats should never get a default value, since the conversion is not lossless reversible and rclone move would destroy the original files this way.

@B4dM4n
B4dM4n force-pushed the drive_import_formats branch 3 times, most recently from 8530ea5 to a3eaf3f Compare August 30, 2018 23:28
@B4dM4n

B4dM4n commented Aug 31, 2018

Copy link
Copy Markdown
Collaborator Author

The next iteration of changes is done. I found another half dozen bugs and fixed the handling of apps-scripts. The documentation is also updated.

This PR should now be ready to be tested. I will upload it as a beta branch soon and link it in the related issues.

@ncw Should I merge cd8c955 and d1e708a into master already? They don't change the current behavior and would shrink the diff of this PR a bit.

@ncw

ncw commented Sep 1, 2018

Copy link
Copy Markdown
Member

Happy for you to merge those commits after I get the release out the door (should be today hopefully!)

@ncw

ncw commented Sep 2, 2018 •

Copy link
Copy Markdown
Member

OK the release is done! Happy you for you to merge away :-)

@B4dM4n
B4dM4n force-pushed the drive_import_formats branch from 6a66967 to 9a083bd Compare September 3, 2018 10:34
@ncw

ncw commented Sep 24, 2018

Copy link
Copy Markdown
Member

Is this ready to merge @B4dM4n ?

Make use of the mime package to find matching extensions and mime types.
For simplicity, all extensions are now prefixed with "." to match the
mime package requirements.

Parsed extensions get converted if needed.
Add a new flag to the drive backend to allow document conversions oni upload.
The existing --drive-formats flag has been renamed to --drive-export-formats.
The old flag is still working to be backward compatible.
@B4dM4n
B4dM4n force-pushed the drive_import_formats branch from 9a083bd to 75b793c Compare September 25, 2018 11:46
@B4dM4n

B4dM4n commented Sep 25, 2018

Copy link
Copy Markdown
Collaborator Author

There didn't arise new bugs since the last iteration in my testing and no other reported problems.

I rebased the code and it should be ready for beta.

@ncw

ncw commented Sep 25, 2018

Copy link
Copy Markdown
Member

OK I'll merge that now and we can keep an eye on bug reports and the integration tests :-)

Thank you :-)

@ncw
ncw merged commit a20fae0 into rclone:master Sep 25, 2018
@B4dM4n
B4dM4n deleted the drive_import_formats branch September 25, 2018 16:48
@mhagnumdw

Copy link
Copy Markdown

Is the --drive-export-formats=.link.html option documented somewhere?

@ncw

ncw commented Nov 12, 2019

Copy link
Copy Markdown
Member

See: https://rclone.org/drive/#import-export-of-google-documents

@ivandeex ivandeex mentioned this pull request May 15, 2021
38 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants