b2: Fix SHA1 mismatch when downloading files with no SHA1 #678

Some large files (depending on which version of rclone they were
uploaded with and where they were uploaded from) don't have an SHA1,
so we can't check it in that case.
This commit is contained in:
Nick Craig-Wood 2017-08-31 21:19:54 +01:00
parent 921fcc0723
commit 8207af9460

View File

@ -1133,7 +1133,7 @@ func (file *openFile) Close() (err error) {
// Check the SHA1
receivedSHA1 := file.o.sha1
calculatedSHA1 := fmt.Sprintf("%x", file.hash.Sum(nil))
if receivedSHA1 != calculatedSHA1 {
if receivedSHA1 != "" && receivedSHA1 != calculatedSHA1 {
return errors.Errorf("object corrupted on transfer - SHA1 mismatch (want %q got %q)", receivedSHA1, calculatedSHA1)
}