From e2fde62cd9eefbbd8972e4565d298ba791a27c54 Mon Sep 17 00:00:00 2001 From: Garry McNulty Date: Sat, 25 May 2019 11:27:30 +0100 Subject: [PATCH] drive: add --drive-size-as-quota to show storage quota usage for file size - fixes #3135 --- backend/drive/drive.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 63d71aa9b..943ec46a5 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -367,6 +367,14 @@ will download it anyway.`, Default: false, Help: "Keep new head revision of each file forever.", Advanced: true, + }, { + Name: "size_as_quota", + Default: false, + Help: `Show storage quota usage for file size. + +The storage used by a file is the size of the current version plus any +older versions that have been set to keep forever.`, + Advanced: true, }, { Name: "v2_download_min_size", Default: fs.SizeSuffix(-1), @@ -434,6 +442,7 @@ type Options struct { ChunkSize fs.SizeSuffix `config:"chunk_size"` AcknowledgeAbuse bool `config:"acknowledge_abuse"` KeepRevisionForever bool `config:"keep_revision_forever"` + SizeAsQuota bool `config:"size_as_quota"` V2DownloadMinSize fs.SizeSuffix `config:"v2_download_min_size"` PacerMinSleep fs.Duration `config:"pacer_min_sleep"` PacerBurst int `config:"pacer_burst"` @@ -643,6 +652,9 @@ func (f *Fs) list(dirIDs []string, title string, directoriesOnly, filesOnly, inc if f.opt.SkipChecksumGphotos { fields += ",spaces" } + if f.opt.SizeAsQuota { + fields += ",quotaBytesUsed" + } fields = fmt.Sprintf("files(%s),nextPageToken", fields) @@ -1018,13 +1030,17 @@ func (f *Fs) newBaseObject(remote string, info *drive.File) baseObject { if f.opt.UseCreatedDate { modifiedDate = info.CreatedTime } + size := info.Size + if f.opt.SizeAsQuota { + size = info.QuotaBytesUsed + } return baseObject{ fs: f, remote: remote, id: info.Id, modifiedDate: modifiedDate, mimeType: info.MimeType, - bytes: info.Size, + bytes: size, } }