Implement --ignore-checksum flag

Fixes #793 Fixes #863 Fixes #981
This commit is contained in:
Nick Craig-Wood 2017-01-05 17:32:42 +00:00
parent 916569102c
commit 9d331ce04b
3 changed files with 13 additions and 1 deletions

View file

@ -313,6 +313,15 @@ Do a trial run with no permanent changes. Use this to see what rclone
would do without actually doing it. Useful when setting up the `sync` would do without actually doing it. Useful when setting up the `sync`
command which deletes files in the destination. command which deletes files in the destination.
### --ignore-checksum ###
Normally rclone will check that the checksums of transferred files
match, and give an error "corrupted on transfer" if they don't.
You can use this option to skip that check. You should only use it if
you have had the "corrupted on transfer" error message and you are
sure you might want to transfer potentially corrupted data.
### --ignore-existing ### ### --ignore-existing ###
Using this option will make rclone unconditionally skip all files Using this option will make rclone unconditionally skip all files

View file

@ -83,6 +83,7 @@ var (
noGzip = BoolP("no-gzip-encoding", "", false, "Don't set Accept-Encoding: gzip.") noGzip = BoolP("no-gzip-encoding", "", false, "Don't set Accept-Encoding: gzip.")
maxDepth = IntP("max-depth", "", -1, "If set limits the recursion depth to this.") maxDepth = IntP("max-depth", "", -1, "If set limits the recursion depth to this.")
ignoreSize = BoolP("ignore-size", "", false, "Ignore size when skipping use mod-time or checksum.") ignoreSize = BoolP("ignore-size", "", false, "Ignore size when skipping use mod-time or checksum.")
ignoreChecksum = BoolP("ignore-checksum", "", false, "Skip post copy check of checksums.")
noTraverse = BoolP("no-traverse", "", false, "Don't traverse destination file system on copy.") noTraverse = BoolP("no-traverse", "", false, "Don't traverse destination file system on copy.")
noUpdateModTime = BoolP("no-update-modtime", "", false, "Don't update destination mod-time if files identical.") noUpdateModTime = BoolP("no-update-modtime", "", false, "Don't update destination mod-time if files identical.")
backupDir = StringP("backup-dir", "", "", "Make backups into hierarchy based in DIR.") backupDir = StringP("backup-dir", "", "", "Make backups into hierarchy based in DIR.")
@ -207,6 +208,7 @@ type ConfigInfo struct {
NoGzip bool // Disable compression NoGzip bool // Disable compression
MaxDepth int MaxDepth int
IgnoreSize bool IgnoreSize bool
IgnoreChecksum bool
NoTraverse bool NoTraverse bool
NoUpdateModTime bool NoUpdateModTime bool
DataRateUnit string DataRateUnit string
@ -308,6 +310,7 @@ func LoadConfig() {
Config.NoGzip = *noGzip Config.NoGzip = *noGzip
Config.MaxDepth = *maxDepth Config.MaxDepth = *maxDepth
Config.IgnoreSize = *ignoreSize Config.IgnoreSize = *ignoreSize
Config.IgnoreChecksum = *ignoreChecksum
Config.NoTraverse = *noTraverse Config.NoTraverse = *noTraverse
Config.NoUpdateModTime = *noUpdateModTime Config.NoUpdateModTime = *noUpdateModTime
Config.BackupDir = *backupDir Config.BackupDir = *backupDir

View file

@ -331,7 +331,7 @@ func Copy(f Fs, dst Object, remote string, src Object) (err error) {
if err != nil { if err != nil {
Stats.Error() Stats.Error()
ErrorLog(dst, "Failed to read hash: %v", err) ErrorLog(dst, "Failed to read hash: %v", err)
} else if !HashEquals(srcSum, dstSum) { } else if !Config.IgnoreSize && !HashEquals(srcSum, dstSum) {
Stats.Error() Stats.Error()
err = errors.Errorf("corrupted on transfer: %v hash differ %q vs %q", hashType, srcSum, dstSum) err = errors.Errorf("corrupted on transfer: %v hash differ %q vs %q", hashType, srcSum, dstSum)
ErrorLog(dst, "%v", err) ErrorLog(dst, "%v", err)