lib/scanner: Recheck file size and modification time after hashing (ref #3440)
To catch the case where the file changed. Also make sure we never let a size-vs-blocklist mismatch slip through. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3443
This commit is contained in:
@@ -51,7 +51,7 @@ var blocksTestData = []struct {
|
||||
func TestBlocks(t *testing.T) {
|
||||
for _, test := range blocksTestData {
|
||||
buf := bytes.NewBuffer(test.data)
|
||||
blocks, err := Blocks(buf, test.blocksize, 0, nil)
|
||||
blocks, err := Blocks(buf, test.blocksize, -1, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -105,8 +105,8 @@ var diffTestData = []struct {
|
||||
|
||||
func TestDiff(t *testing.T) {
|
||||
for i, test := range diffTestData {
|
||||
a, _ := Blocks(bytes.NewBufferString(test.a), test.s, 0, nil)
|
||||
b, _ := Blocks(bytes.NewBufferString(test.b), test.s, 0, nil)
|
||||
a, _ := Blocks(bytes.NewBufferString(test.a), test.s, -1, nil)
|
||||
b, _ := Blocks(bytes.NewBufferString(test.b), test.s, -1, nil)
|
||||
_, d := BlockDiff(a, b)
|
||||
if len(d) != len(test.d) {
|
||||
t.Fatalf("Incorrect length for diff %d; %d != %d", i, len(d), len(test.d))
|
||||
|
||||
Reference in New Issue
Block a user