From 5b09599a23e455f342f54cecaf2a3174d1e9bf79 Mon Sep 17 00:00:00 2001 From: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> Date: Wed, 7 Oct 2020 10:24:37 +0530 Subject: [PATCH] drive: Added flag `--drive-stop-on-download-limit` to stop transfers when the download limit is exceeded Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com> --- backend/drive/drive.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 18d47c928..eeb0beede 100755 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -471,6 +471,21 @@ Note that this detection is relying on error message strings which Google don't document so it may break in the future. See: https://github.com/rclone/rclone/issues/3857 +`, + Advanced: true, + }, { + Name: "stop_on_download_limit", + Default: false, + Help: `Make download limit errors be fatal + +At the time of writing it is only possible to download 10TB of data from +Google Drive a day (this is an undocumented limit). When this limit is +reached Google Drive produces a slightly different error message. When +this flag is set it causes these errors to be fatal. These will stop +the in-progress sync. + +Note that this detection is relying on error message strings which +Google don't document so it may break in the future. `, Advanced: true, }, { @@ -540,6 +555,7 @@ type Options struct { ServerSideAcrossConfigs bool `config:"server_side_across_configs"` DisableHTTP2 bool `config:"disable_http2"` StopOnUploadLimit bool `config:"stop_on_upload_limit"` + StopOnDownloadLimit bool `config:"stop_on_download_limit"` SkipShortcuts bool `config:"skip_shortcuts"` Enc encoder.MultiEncoder `config:"encoding"` } @@ -639,6 +655,9 @@ func (f *Fs) shouldRetry(err error) (bool, error) { return false, fserrors.FatalError(err) } return true, err + } else if f.opt.StopOnDownloadLimit && reason == "downloadQuotaExceeded" { + fs.Errorf(f, "Received download limit error: %v", err) + return false, fserrors.FatalError(err) } else if f.opt.StopOnUploadLimit && reason == "teamDriveFileLimitExceeded" { fs.Errorf(f, "Received team drive file limit error: %v", err) return false, fserrors.FatalError(err)