From b9fc83217d55fd8f6d05fb616c227f7a9c4678a7 Mon Sep 17 00:00:00 2001 From: Sulthan Zaki Date: Sat, 22 Aug 2026 09:05:53 +0700 Subject: [PATCH] #150: address covers by bytes; ReplaceSeriesCover --- backend/cover_test.go | 8 +- backend/internal/latest/acquire_test.go | 14 +- backend/internal/latest/poller_test.go | 24 ++- backend/internal/latest/smoke_image_test.go | 20 ++- .../migrations/0009_series_cover_address.sql | 13 +- backend/internal/store/store.go | 110 ++++++++++---- backend/internal/store/store_test.go | 140 ++++++++++++++++-- docs/adr/0014-cover-addresses-from-bytes.md | 86 +++++++++++ 8 files changed, 338 insertions(+), 77 deletions(-) create mode 100644 docs/adr/0014-cover-addresses-from-bytes.md diff --git a/backend/cover_test.go b/backend/cover_test.go index 9c3c93f..87db88a 100644 --- a/backend/cover_test.go +++ b/backend/cover_test.go @@ -32,7 +32,7 @@ func TestPublicCoverServesStoredBytesUnauthenticated(t *testing.T) { // The wire URL is what a client actually requests, so the path under test // is taken from it rather than rebuilt by hand. - wire := st.CoverWireURL(store.CoverAddress(sourceURL)) + wire := st.CoverWireURL(store.CoverAddressForBytes([]byte("\x00webp-bytes"))) path, ok := strings.CutPrefix(wire, testCoverBaseURL) if !ok { t.Fatalf("wire URL %q is not on the public origin %q", wire, testCoverBaseURL) @@ -57,7 +57,7 @@ func TestPublicCoverServesStoredBytesUnauthenticated(t *testing.T) { func TestPublicCoverRejectsUnknownAddress(t *testing.T) { srv, _ := newWebTestServer(t, testConfig()) cases := map[string]string{ - "unknown": "/covers/" + store.CoverAddress("https://cdn.example/never-stored.jpg"), + "unknown": "/covers/" + store.CoverAddressForBytes([]byte("never-stored")), "malformed": "/covers/not-an-address", "traversal": "/covers/../../etc/passwd", "empty": "/covers/", @@ -86,7 +86,7 @@ func TestPublicCoverNeverEchoesNonImage(t *testing.T) { } // A legitimate row, then the content type flipped behind the store's back: // the bytes exist at the address, so only the type is hostile. - address := store.CoverAddress(sourceURL) + address := store.CoverAddressForBytes([]byte("