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

Make check return errors on differences
This commit is contained in:
Nick Craig-Wood 2013-01-10 22:14:23 +00:00
parent 555ab5001e
commit 8b066ba77c
2 changed files with 9 additions and 2 deletions

View File

@ -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 {

View File

@ -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