operations: warn if --checksum is set but there are no hashes available

Also caveat the help of --checksum

Fixes #2903
This commit is contained in:
Nick Craig-Wood
2019-01-10 11:07:10 +00:00
parent 2e6ef4f6ec
commit ff72059a94
2 changed files with 6 additions and 1 deletions

View File

@@ -104,6 +104,8 @@ func sizeDiffers(src, dst fs.ObjectInfo) bool {
return src.Size() != dst.Size()
}
var checksumWarning sync.Once
func equal(src fs.ObjectInfo, dst fs.Object, sizeOnly, checkSum bool) bool {
if sizeDiffers(src, dst) {
fs.Debugf(src, "Sizes differ (src %d vs dst %d)", src.Size(), dst.Size())
@@ -125,6 +127,9 @@ func equal(src fs.ObjectInfo, dst fs.Object, sizeOnly, checkSum bool) bool {
return false
}
if ht == hash.None {
checksumWarning.Do(func() {
fs.Logf(dst.Fs(), "--checksum is in use but the source and destination have no hashes in common; falling back to --size-only")
})
fs.Debugf(src, "Size of src and dst objects identical")
} else {
fs.Debugf(src, "Size and %v of src and dst objects identical", ht)