Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

bisync: fix memory leak when running via the rc

nielash387b4b5e11d6
diff --git a/cmd/bisync/queue.go b/cmd/bisync/queue.go
index 58588baef..20ef152ba 100644
--- a/cmd/bisync/queue.go
+++ b/cmd/bisync/queue.go
@@ -247,7 +247,9 @@ func (b *bisyncRun) fastCopy(ctx context.Context, fsrc, fdst fs.Fs, files bilib.
b.SyncCI = fs.GetConfig(ctxCopy) // allows us to request graceful shutdown
accounting.Stats(ctxCopy).SetMaxCompletedTransfers(-1) // we need a complete list in the event of graceful shutdown
- ctxCopy, b.CancelSync = context.WithCancel(ctxCopy)
+ ctxCopy, cancel := context.WithCancel(ctxCopy)
+ defer cancel()
+ b.CancelSync = cancel
b.testFn()
err := sync.Sync(ctxCopy, fdst, fsrc, b.opt.CreateEmptySrcDirs)
prettyprint(b.queueOpt.logger, "b.queueOpt.logger", fs.LogLevelDebug)