Keep cached sources and variants in one FileStore type (closes #318)
check / check (push) Canceled after 0s

imgcache.FileStore is a directory of files named by a hex key, at
<ab>/<cd>/<key>. It writes a file under a temp name, syncs it and renames
it into place. It opens, reports the size of and deletes the file for a
key. The cache keeps its sources in one FileStore and its variants in
another, so ContentStorage and VariantStorage are gone. FileStore has no
Exists: the reconciliation pass checks a variant's file with Size, and the
tests look for the file on disk. Cache.Variant reads the content type from
the file's first bytes itself. storage.go is now filestore.go, and the
unused testdata/red.avif is gone.

Model: opus-5-5
This commit was merged in pull request #335.
This commit is contained in:
2026-10-26 20:24:33 +01:00
parent 17376d885b
commit ac850823f4
12 changed files with 496 additions and 535 deletions
@@ -74,7 +74,8 @@ func TestEvictSourceBlob_LeavesSourceWithIdenticalBytesServed(t *testing.T) {
t.Fatalf("evictSourceBlob() error = %v", err)
}
if cache.srcContent.Exists(evicted) {
_, err = os.Stat(cache.srcContent.keyToPath(string(evicted)))
if err == nil {
t.Error("the evicted source's file is still on disk")
}
@@ -129,7 +130,8 @@ func TestPutSource_FailedRowWriteLeavesNoFile(t *testing.T) {
t.Error("PutSource() error = nil, want the failed row write")
}
if cache.srcContent.Exists(req.Source.Key()) {
_, err = os.Stat(cache.srcContent.keyToPath(string(req.Source.Key())))
if err == nil {
t.Error("the source's file is on disk although its row was not written")
}
}