feat: add webp cover previews and cache pruning
CI / test (push) Successful in 23s

This commit is contained in:
strsv committed 2026-11-06 17:33:04 +03:00
1 parent b2ab347129
commit adc832c042
14 files changed
+336 -24

No files matched your search

+14
View File
@@ -406,6 +406,20 @@ class ApiTests(unittest.TestCase):
self.get("/api/cover/3", expect=404)
self.assertEqual(download.call_count, calls * 2, "expired marker should retry")
def test_cover_prefers_webp_preview(self):
with tempfile.TemporaryDirectory() as covers_dir, \
mock.patch.object(server, "CACHE_DIR", covers_dir):
app_dir = os.path.join(covers_dir, "1")
os.makedirs(app_dir)
with open(os.path.join(app_dir, "header.jpg"), "wb") as fh:
fh.write(b"jpeg-bytes")
with open(os.path.join(app_dir, "preview.webp"), "wb") as fh:
fh.write(b"webp-bytes")
body, content_type, _ = self.raw_get("/api/cover/1")
self.assertEqual(body, b"webp-bytes")
self.assertEqual(content_type, "image/webp")
def test_cached_cover_clears_negative_marker(self):
with tempfile.TemporaryDirectory() as covers, \
mock.patch.object(server, "CACHE_DIR", covers):