Disk cache: version the poster folder

Posters stored by the previous build (the downloaded bytes, for real
images Radarr's 333x500 copy) were reused as they were for 30 days.
Posters now live in posters-v2/; older folders are deleted at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 11:41:11 +02:00
co-authored by Claude Opus 5.5
parent 15e97f4582
commit ca8c71fa52
4 changed files with 33 additions and 4 deletions
+16
View File
@@ -105,3 +105,19 @@ func TestPeopleCacheKeepsTheNewest(t *testing.T) {
t.Error("new casts must be written")
}
}
func TestPostersOfOlderVersionsAreDropped(t *testing.T) {
d := &diskCache{dir: t.TempDir()}
old := filepath.Join(d.dir, "posters", "abc.img")
if err := writeAtomic(old, []byte("v1")); err != nil {
t.Fatal(err)
}
d.writePoster("k", true, []byte("v2"))
d.prunePosters()
if _, err := os.Stat(old); !os.IsNotExist(err) {
t.Error("a poster of the old format was kept")
}
if data, ok := d.readPoster("k", true); !ok || string(data) != "v2" {
t.Error("the current poster was dropped")
}
}