mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-12 16:26:37 +00:00
This commit is contained in:
parent
79360e2205
commit
fca895a632
@ -1576,7 +1576,7 @@ func (m *model) Request(deviceID protocol.DeviceID, folder, name string, size in
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !scanner.Validate(res.data, hash, weakHash) {
|
if !scanner.Validate(res.data, hash, weakHash) {
|
||||||
m.recheckFile(deviceID, folderFs, folder, name, int(offset)/int(size), hash)
|
m.recheckFile(deviceID, folderFs, folder, name, size, offset, hash)
|
||||||
l.Debugf("%v REQ(in) failed validating data (%v): %s: %q / %q o=%d s=%d", m, err, deviceID, folder, name, offset, size)
|
l.Debugf("%v REQ(in) failed validating data (%v): %s: %q / %q o=%d s=%d", m, err, deviceID, folder, name, offset, size)
|
||||||
return nil, protocol.ErrNoSuchFile
|
return nil, protocol.ErrNoSuchFile
|
||||||
}
|
}
|
||||||
@ -1584,7 +1584,7 @@ func (m *model) Request(deviceID protocol.DeviceID, folder, name string, size in
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) recheckFile(deviceID protocol.DeviceID, folderFs fs.Filesystem, folder, name string, blockIndex int, hash []byte) {
|
func (m *model) recheckFile(deviceID protocol.DeviceID, folderFs fs.Filesystem, folder, name string, size int32, offset int64, hash []byte) {
|
||||||
cf, ok := m.CurrentFolderFile(folder, name)
|
cf, ok := m.CurrentFolderFile(folder, name)
|
||||||
if !ok {
|
if !ok {
|
||||||
l.Debugf("%v recheckFile: %s: %q / %q: no current file", m, deviceID, folder, name)
|
l.Debugf("%v recheckFile: %s: %q / %q: no current file", m, deviceID, folder, name)
|
||||||
@ -1596,6 +1596,7 @@ func (m *model) recheckFile(deviceID protocol.DeviceID, folderFs fs.Filesystem,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockIndex := int(offset) / cf.BlockSize()
|
||||||
if blockIndex >= len(cf.Blocks) {
|
if blockIndex >= len(cf.Blocks) {
|
||||||
l.Debugf("%v recheckFile: %s: %q / %q i=%d: block index too far", m, deviceID, folder, name, blockIndex)
|
l.Debugf("%v recheckFile: %s: %q / %q i=%d: block index too far", m, deviceID, folder, name, blockIndex)
|
||||||
return
|
return
|
||||||
|
@ -3423,11 +3423,11 @@ func TestIssue5002(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("test file should exist")
|
t.Fatal("test file should exist")
|
||||||
}
|
}
|
||||||
nBlocks := len(file.Blocks)
|
blockSize := int32(file.BlockSize())
|
||||||
|
|
||||||
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks-1, []byte{1, 2, 3, 4})
|
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", blockSize, file.Size-int64(blockSize), []byte{1, 2, 3, 4})
|
||||||
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks, []byte{1, 2, 3, 4}) // panic
|
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", blockSize, file.Size, []byte{1, 2, 3, 4}) // panic
|
||||||
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", nBlocks+1, []byte{1, 2, 3, 4})
|
m.recheckFile(protocol.LocalDeviceID, defaultFolderConfig.Filesystem(), "default", "foo", blockSize, file.Size+int64(blockSize), []byte{1, 2, 3, 4})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParentOfUnignored(t *testing.T) {
|
func TestParentOfUnignored(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user