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

Don't delete files if errors in copy phase of sync

Nick Craig-Wood8b066ba77cc1
diff --git a/notes.txt b/notes.txt
index fa54b0f9d..8c3d67522 100644
--- a/notes.txt
+++ b/notes.txt
@@ -2,7 +2,6 @@ Todo
* Factor fses into own packages
* FIXME: ls without an argument for buckets/containers?
* FIXME: More -dry-run checks for object transfer
- * FIXME: don't delete in sync if errors
* Might be quicker to check md5sums first? for swift <-> swift certainly, and maybe for small files
* Ignoring the pseudo directories
* if object.PseudoDirectory {
diff --git a/swiftsync.go b/swiftsync.go
index c4db9d340..3e6bd3d30 100644
--- a/swiftsync.go
+++ b/swiftsync.go
@@ -173,7 +173,10 @@ func Sync(fdst, fsrc Fs) {
log.Printf("Waiting for transfers to finish")
copierWg.Wait()
- // FIXME don't delete if IO errors
+ if stats.errors != 0 {
+ log.Printf("Not deleting files as there were IO errors")
+ return
+ }
// Delete the spare files
toDelete := make(FsObjectsChan, *transfers)
@@ -213,11 +216,13 @@ func Check(fdst, fsrc Fs) {
log.Printf("Files in %s but not in %s", fdst, fsrc)
for remote := range dstFiles {
+ stats.Error()
log.Printf(remote)
}
log.Printf("Files in %s but not in %s", fsrc, fdst)
for remote := range srcFiles {
+ stats.Error()
log.Printf(remote)
}
@@ -239,6 +244,7 @@ func Check(fdst, fsrc Fs) {
stats.Checking(src)
if src.Size() != dst.Size() {
stats.DoneChecking(src)
+ stats.Error()
FsLog(src, "Sizes differ")
continue
}
@@ -248,6 +254,7 @@ func Check(fdst, fsrc Fs) {
continue
}
if !same {
+ stats.Error()
FsLog(src, "Md5sums differ")
}
FsDebug(src, "OK")
@@ -257,6 +264,7 @@ func Check(fdst, fsrc Fs) {
log.Printf("Waiting for checks to finish")
checkerWg.Wait()
+ log.Printf("%d differences found", stats.errors)
}
// List the Fs to stdout