diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 4974fee5d..243adb067 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -55,6 +55,7 @@ const ( timeFormatIn = time.RFC3339 timeFormatOut = "2006-01-02T15:04:05.000000000Z07:00" defaultMinSleep = fs.Duration(100 * time.Millisecond) + defaultBurst = 100 defaultExportExtensions = "docx,xlsx,pptx,svg" scopePrefix = "https://www.googleapis.com/auth/" defaultScope = "drive" @@ -361,6 +362,11 @@ will download it anyway.`, Default: defaultMinSleep, Help: "Minimum time to sleep between API calls.", Advanced: true, + }, { + Name: "pacer_burst", + Default: defaultBurst, + Help: "Number of API calls to allow without sleeping.", + Advanced: true, }}, }) @@ -404,6 +410,7 @@ type Options struct { KeepRevisionForever bool `config:"keep_revision_forever"` V2DownloadMinSize fs.SizeSuffix `config:"v2_download_min_size"` PacerMinSleep fs.Duration `config:"pacer_min_sleep"` + PacerBurst int `config:"pacer_burst"` } // Fs represents a remote drive server @@ -781,7 +788,7 @@ func configTeamDrive(opt *Options, m configmap.Mapper, name string) error { // newPacer makes a pacer configured for drive func newPacer(opt *Options) *pacer.Pacer { - return pacer.New().SetMinSleep(time.Duration(opt.PacerMinSleep)).SetPacer(pacer.GoogleDrivePacer) + return pacer.New().SetMinSleep(time.Duration(opt.PacerMinSleep)).SetBurst(opt.PacerBurst).SetPacer(pacer.GoogleDrivePacer) } func getServiceAccountClient(opt *Options, credentialsData []byte) (*http.Client, error) { diff --git a/lib/pacer/pacer.go b/lib/pacer/pacer.go index 6322ae86e..3914950ad 100644 --- a/lib/pacer/pacer.go +++ b/lib/pacer/pacer.go @@ -234,7 +234,7 @@ func (p *Pacer) beginCall() { // fs.Debugf(f, "New sleep for %v at %v", t, time.Now()) // Sleep the minimum time with the rate limiter if minSleep > 0 && sleepTime >= minSleep { - p.limiter.Wait(context.Background()) + _ = p.limiter.Wait(context.Background()) sleepTime -= minSleep } // Then sleep the remaining time