From 06ecc6511b07924303f081928167d7fb67841215 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 22 Feb 2022 16:38:46 +0000 Subject: [PATCH] drive: when using a link type --drive-export-formats show all doc types Before this change we always hid unexportable document types (eg Google maps). After this change, if using --drive-export-formats url/desktop/link.html/webloc we will show links for all documents regardless of whether they are exportable or not as the links to them work regardless of whether they are exportable or not. See: https://forum.rclone.org/t/rclone-mount-for-google-drive-does-not-show-as-web-links-the-google-documents-of-the-google-my-map-gmap-type/29415 --- backend/drive/drive.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 18e29d251..1ff28a434 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -1597,6 +1597,15 @@ func (f *Fs) findExportFormatByMimeType(ctx context.Context, itemMimeType string } } + // If using a link type export and a more specific export + // hasn't been found all docs should be exported + for _, _extension := range f.exportExtensions { + _mimeType := mime.TypeByExtension(_extension) + if isLinkMimeType(_mimeType) { + return _extension, _mimeType, true + } + } + // else return empty return "", "", isDocument } @@ -1607,6 +1616,14 @@ func (f *Fs) findExportFormatByMimeType(ctx context.Context, itemMimeType string // Look through the exportExtensions and find the first format that can be // converted. If none found then return ("", "", "", false) func (f *Fs) findExportFormat(ctx context.Context, item *drive.File) (extension, filename, mimeType string, isDocument bool) { + // If item has MD5 sum it is a file stored on drive + if item.Md5Checksum != "" { + return + } + // Folders can't be documents + if item.MimeType == driveFolderType { + return + } extension, mimeType, isDocument = f.findExportFormatByMimeType(ctx, item.MimeType) if extension != "" { filename = item.Name + extension