|
|
@@ -1524,7 +1524,7 @@ func (m *model) Request(deviceID protocol.DeviceID, folder, name string, size in
|
|
|
}
|
|
|
|
|
|
if !scanner.Validate(res.data, hash, weakHash) {
|
|
|
- m.recheckFile(deviceID, folder, name, offset, hash)
|
|
|
+ m.recheckFile(deviceID, folder, name, offset, hash, weakHash)
|
|
|
l.Debugf("%v REQ(in) failed validating data: %s: %q / %q o=%d s=%d", m, deviceID, folder, name, offset, size)
|
|
|
return nil, protocol.ErrNoSuchFile
|
|
|
}
|
|
|
@@ -1558,7 +1558,7 @@ func newLimitedRequestResponse(size int, limiters ...*byteSemaphore) *requestRes
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
-func (m *model) recheckFile(deviceID protocol.DeviceID, folder, name string, offset int64, hash []byte) {
|
|
|
+func (m *model) recheckFile(deviceID protocol.DeviceID, folder, name string, offset int64, hash []byte, weakHash uint32) {
|
|
|
cf, ok := m.CurrentFolderFile(folder, name)
|
|
|
if !ok {
|
|
|
l.Debugf("%v recheckFile: %s: %q / %q: no current file", m, deviceID, folder, name)
|
|
|
@@ -1583,6 +1583,10 @@ func (m *model) recheckFile(deviceID protocol.DeviceID, folder, name string, off
|
|
|
l.Debugf("%v recheckFile: %s: %q / %q i=%d: hash mismatch %x != %x", m, deviceID, folder, name, blockIndex, block.Hash, hash)
|
|
|
return
|
|
|
}
|
|
|
+ if weakHash != 0 && block.WeakHash != weakHash {
|
|
|
+ l.Debugf("%v recheckFile: %s: %q / %q i=%d: weak hash mismatch %v != %v", m, deviceID, folder, name, blockIndex, block.WeakHash, weakHash)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// The hashes provided part of the request match what we expect to find according
|
|
|
// to what we have in the database, yet the content we've read off the filesystem doesn't
|