Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e814bf0ba |
@@ -427,8 +427,8 @@ operands:
|
|||||||
- A file whose mtime is newer than recorded, or whose size differs, is processed
|
- A file whose mtime is newer than recorded, or whose size differs, is processed
|
||||||
as if new: re-hashed, or recorded without hashes, per the shared-size rule.
|
as if new: re-hashed, or recorded without hashes, per the shared-size rule.
|
||||||
Change detection compares the mtime to the nanosecond, as finely as the
|
Change detection compares the mtime to the nanosecond, as finely as the
|
||||||
filesystem records it, so a same-size rewrite counts as a change whenever the
|
filesystem records it, so a same-size rewrite later in the same second as the
|
||||||
filesystem gives it a later mtime than recorded, even within the same second.
|
recorded mtime still counts as a change.
|
||||||
- A database record whose path lies under one of the scanned operands but was
|
- A database record whose path lies under one of the scanned operands but was
|
||||||
not successfully processed this run is deleted. This removes records for
|
not successfully processed this run is deleted. This removes records for
|
||||||
deleted files. It also removes records for paths that failed to stat or hash
|
deleted files. It also removes records for paths that failed to stat or hash
|
||||||
|
|||||||
+2
-67
@@ -20,8 +20,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// writeFile creates a file with the given content and returns its path.
|
// writeFile creates a file with the given content and returns its path.
|
||||||
@@ -583,65 +581,6 @@ func TestScanContentHashedStalePartners(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestScanContentSameSecondRewrite is TestScanContentStalePartners for
|
|
||||||
// a stored file rewritten in place at the same size with an mtime later
|
|
||||||
// in the same second than recorded: the file counts as changed, so
|
|
||||||
// neither it nor its match inside the operand is read.
|
|
||||||
func TestScanContentSameSecondRewrite(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
db := openTestDB(t)
|
|
||||||
dirA := t.TempDir()
|
|
||||||
changed := sparseFileWithoutMatch(t, dirA, "changed", headTailMin)
|
|
||||||
|
|
||||||
first := time.Date(2026, 1, 2, 3, 4, 5, 100_000_000, time.UTC)
|
|
||||||
|
|
||||||
err := os.Chtimes(changed, first, first)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
syncTree(t, db, dirA)
|
|
||||||
|
|
||||||
before := dbRecords(t, db)
|
|
||||||
|
|
||||||
// Rewrite one byte in place, keeping the size.
|
|
||||||
pokeAt(t, changed, headTailMin/2, []byte{1})
|
|
||||||
|
|
||||||
later := first.Add(500 * time.Millisecond)
|
|
||||||
|
|
||||||
err = os.Chtimes(changed, later, later)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
dirB := t.TempDir()
|
|
||||||
sparseFile(t, dirB, "changed-copy", headTailMin)
|
|
||||||
|
|
||||||
st := syncTree(t, db, dirB)
|
|
||||||
if st != (scanStats{walked: 1, added: 1}) {
|
|
||||||
t.Errorf("stats = %+v, want 1 added and nothing skipped", st)
|
|
||||||
}
|
|
||||||
|
|
||||||
recs := dbRecords(t, db)
|
|
||||||
for _, r := range recs {
|
|
||||||
if r.content != "" {
|
|
||||||
t.Errorf("%s: content = %q, want none: its only match is stale",
|
|
||||||
r.path, r.content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, old := range before {
|
|
||||||
if r := recordByPath(t, recs, old.path); r != old {
|
|
||||||
t.Errorf("record = %+v, want it left as %+v", r, old)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if groups := dupeGroups(t, db); len(groups) != 0 {
|
|
||||||
t.Errorf("groups = %+v, want none", groups)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestScanContentReadFailure checks that a failed content read is
|
// TestScanContentReadFailure checks that a failed content read is
|
||||||
// counted as skipped and leaves the record without a content hash, and
|
// counted as skipped and leaves the record without a content hash, and
|
||||||
// that a later scan tries the read again.
|
// that a later scan tries the read again.
|
||||||
@@ -1466,13 +1405,9 @@ func TestSyncScanRewriteAfter2262(t *testing.T) {
|
|||||||
|
|
||||||
// os.Chtimes cannot set this time: it converts through UnixNano.
|
// os.Chtimes cannot set this time: it converts through UnixNano.
|
||||||
late := time.Date(2300, 1, 2, 3, 4, 5, 0, time.UTC)
|
late := time.Date(2300, 1, 2, 3, 4, 5, 0, time.UTC)
|
||||||
|
ts := syscall.Timespec{Sec: late.Unix()}
|
||||||
|
|
||||||
ts, err := unix.TimeToTimespec(late)
|
err := syscall.UtimesNano(a, []syscall.Timespec{ts, ts})
|
||||||
if err != nil {
|
|
||||||
t.Skipf("%v does not fit this platform's timespec: %v", late, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = unix.UtimesNano(a, []unix.Timespec{ts, ts})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user