"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
lib/atexit: ensure OnError only calls cancel function once
Nick Craig-Woodcdfa0beafb39
diff --git a/lib/atexit/atexit.go b/lib/atexit/atexit.goindex 363d3267b..fa1dcc8b7 100644--- a/lib/atexit/atexit.go+++ b/lib/atexit/atexit.go@@ -115,12 +115,18 @@ func Run() {//// So cancelFunc will be run if the function exits with an error or// at exit.+//+// cancelFunc will only be run once.func OnError(perr *error, fn func()) func() {- handle := Register(fn)+ var once sync.Once+ onceFn := func() {+ once.Do(fn)+ }+ handle := Register(onceFn)return func() {defer Unregister(handle)if *perr != nil {- fn()+ onceFn()}}