drive: add --drive-use-shared-date to use date file was shared instead of modified date - fixes #3624

This commit is contained in:
Garry McNulty 2019-11-18 21:34:10 +00:00 committed by Nick Craig-Wood
parent c3751e9a50
commit 11f44cff50

View File

@ -326,6 +326,17 @@ Photos folder" option in your google drive settings. You can then copy
or move the photos locally and use the date the image was taken or move the photos locally and use the date the image was taken
(created) set as the modification date.`, (created) set as the modification date.`,
Advanced: true, Advanced: true,
}, {
Name: "use_shared_date",
Default: false,
Help: `Use date file was shared instead of modified date.
Note that, as with "--drive-use-created-date", this flag may have
unexpected consequences when uploading/downloading files.
If both this flag and "--drive-use-created-date" are set, the created
date is used.`,
Advanced: true,
}, { }, {
Name: "list_chunk", Name: "list_chunk",
Default: 1000, Default: 1000,
@ -463,6 +474,7 @@ type Options struct {
ImportExtensions string `config:"import_formats"` ImportExtensions string `config:"import_formats"`
AllowImportNameChange bool `config:"allow_import_name_change"` AllowImportNameChange bool `config:"allow_import_name_change"`
UseCreatedDate bool `config:"use_created_date"` UseCreatedDate bool `config:"use_created_date"`
UseSharedDate bool `config:"use_shared_date"`
ListChunk int64 `config:"list_chunk"` ListChunk int64 `config:"list_chunk"`
Impersonate string `config:"impersonate"` Impersonate string `config:"impersonate"`
AlternateExport bool `config:"alternate_export"` AlternateExport bool `config:"alternate_export"`
@ -694,6 +706,9 @@ func (f *Fs) list(ctx context.Context, dirIDs []string, title string, directorie
if f.opt.AuthOwnerOnly { if f.opt.AuthOwnerOnly {
fields += ",owners" fields += ",owners"
} }
if f.opt.UseSharedDate {
fields += ",sharedWithMeTime"
}
if f.opt.SkipChecksumGphotos { if f.opt.SkipChecksumGphotos {
fields += ",spaces" fields += ",spaces"
} }
@ -1095,6 +1110,8 @@ func (f *Fs) newBaseObject(remote string, info *drive.File) baseObject {
modifiedDate := info.ModifiedTime modifiedDate := info.ModifiedTime
if f.opt.UseCreatedDate { if f.opt.UseCreatedDate {
modifiedDate = info.CreatedTime modifiedDate = info.CreatedTime
} else if f.opt.UseSharedDate && info.SharedWithMeTime != "" {
modifiedDate = info.SharedWithMeTime
} }
size := info.Size size := info.Size
if f.opt.SizeAsQuota { if f.opt.SizeAsQuota {