A mirror with peers records the checksums of files that had none, so they are copied too

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 18:36:59 +01:00
1 parent 0033a530c7
commit 785e06ecbf
3 files changed
+66

No files matched your search

+26
View File
@@ -172,3 +172,29 @@ func TestAModelsAddressIsMovedToAMirrorThatAnswers(t *testing.T) {
t.Errorf("none up: %s", got)
}
}
// A file fetched before checksums were kept is given one, and is then copied.
func TestAFileWithoutAChecksumIsGivenOneAndThenCopied(t *testing.T) {
a, b := newTestMirror(t), newTestMirror(t)
path := filepath.Join(a.root, "old", "v1", "m.gguf")
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, []byte("fetched long ago"), 0o644); err != nil {
t.Fatal(err)
}
pb := &Peers{M: b.m, Log: discardLog()}
pb.SyncOnce(t.Context(), a.client(t))
time.Sleep(100 * time.Millisecond)
if b.has("old", "v1") {
t.Fatal("copied without a checksum to check it by")
}
if n := a.m.FillChecksums(t.Context()); n != 1 || readChecksum(path) == "" {
t.Fatalf("recorded %d", n)
}
if a.m.FillChecksums(t.Context()) != 0 {
t.Error("recorded again")
}
pb.SyncOnce(t.Context(), a.client(t))
waitPresent(t, b, "old", "v1")
}