"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
Make failed uploads not count as "Transferred" - fixes #708
Nick Craig-Wood83ba59749f4f
diff --git a/b2/b2.go b/b2/b2.goindex b7a300345..fcdf8abf9 100644--- a/b2/b2.go+++ b/b2/b2.go@@ -799,9 +799,9 @@ func (f *Fs) purge(oldOnly bool) error {go func() {defer wg.Done()for object := range toBeDeleted {- fs.Stats.Transferring(object.Name)+ fs.Stats.Checking(object.Name)checkErr(f.deleteByID(object.ID, object.Name))- fs.Stats.DoneTransferring(object.Name)+ fs.Stats.DoneChecking(object.Name)}}()}diff --git a/fs/accounting.go b/fs/accounting.goindex 39b863f72..3f1e9b296 100644--- a/fs/accounting.go+++ b/fs/accounting.go@@ -231,11 +231,15 @@ func (s *StatsInfo) Transferring(remote string) {}// DoneTransferring removes a transfer from the stats-func (s *StatsInfo) DoneTransferring(remote string) {+//+// if ok is true then it increments the transfers count+func (s *StatsInfo) DoneTransferring(remote string, ok bool) {s.lock.Lock()defer s.lock.Unlock()delete(s.transferring, remote)- s.transfers+++ if ok {+ s.transfers+++ }}// Account limits and accounts for one transferdiff --git a/fs/operations.go b/fs/operations.goindex ed49d587a..c6aad3c71 100644--- a/fs/operations.go+++ b/fs/operations.go@@ -1017,8 +1017,11 @@ func CleanUp(f Fs) error {func Cat(f Fs, w io.Writer) error {var mu sync.Mutexreturn ListFn(f, func(o Object) {+ var err errorStats.Transferring(o.Remote())- defer Stats.DoneTransferring(o.Remote())+ defer func() {+ Stats.DoneTransferring(o.Remote(), err == nil)+ }()mu.Lock()defer mu.Unlock()in, err := o.Open()@@ -1041,5 +1044,4 @@ func Cat(f Fs, w io.Writer) error {ErrorLog(o, "Failed to send to output: %v", err)}})-}diff --git a/fs/sync.go b/fs/sync.goindex cdb152d17..8521984bc 100644--- a/fs/sync.go+++ b/fs/sync.go@@ -232,12 +232,14 @@ func (s *syncCopyMove) pairCopier(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup}src := pair.srcStats.Transferring(src.Remote())+ var err errorif Config.DryRun {Log(src, "Not copying as --dry-run")} else {- s.processError(Copy(fdst, pair.dst, src))+ err = Copy(fdst, pair.dst, src)+ s.processError(err)}- Stats.DoneTransferring(src.Remote())+ Stats.DoneTransferring(src.Remote(), err == nil)case <-s.abort:return}@@ -259,6 +261,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)if !ok {return}+ transferredOK := truesrc := pair.srcdst := pair.dstStats.Transferring(src.Remote())@@ -267,6 +270,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)err := Copy(fdst, dst, src)s.processError(err)if err != nil {+ transferredOK = falseErrorLog(src, "Not deleting as copy failed: %v", err)} else {// Delete src if no error on copy@@ -293,6 +297,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)Stats.Error()ErrorLog(dst, "Couldn't move: %v", err)s.processError(err)+ transferredOK = false}} else {Debug(src, "Moved")@@ -300,7 +305,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup)} else {doCopy()}- Stats.DoneTransferring(src.Remote())+ Stats.DoneTransferring(src.Remote(), transferredOK)case <-s.abort:return}