Declare only the tables and columns pixa writes and reads (closes #310)
check / check (push) Waiting to run

Removes output_content and request_cache, which nothing writes, and every
column that was written but never read: the host, path, query, content_type
and fetched_at of source_content, the content_type and created_at of
variant_content, and the status_code, error_message and fetched_at of
negative_cache.

StoreSource no longer takes the fetch result and LookupSource returns only
the source key. StoreVariant no longer takes a content type and
StoreNegative no longer takes a status code or message, so
extractStatusCode and the status constants, which only fed status_code,
are gone. Reconciliation adopts a variant file without opening it, as its
row no longer records a content type. Tests that set or checked a removed
column follow.

Model: opus-5-5
This commit is contained in:
2026-10-21 16:32:49 +00:00
parent 5f9d624d74
commit 03b11e9703
19 changed files with 105 additions and 279 deletions
+6 -14
View File
@@ -113,7 +113,7 @@ func TestImageProxyFlow(t *testing.T) {
}
checkSourceCached(t, db, stateDir, source)
checkVariantCached(t, db, stateDir, first.Body.Bytes(), tt.contentType)
checkVariantCached(t, db, stateDir, first.Body.Bytes())
})
}
}
@@ -276,27 +276,19 @@ func checkSourceCached(t *testing.T, db *sql.DB, stateDir string, source []byte)
}
// checkVariantCached checks that the converted image served is recorded in
// variant_content with contentType, and stored under its cache key in
// cache/variants.
func checkVariantCached(
t *testing.T, db *sql.DB, stateDir string, served []byte, contentType string,
) {
// variant_content, and stored under its cache key in cache/variants.
func checkVariantCached(t *testing.T, db *sql.DB, stateDir string, served []byte) {
t.Helper()
var cacheKey, storedType string
var cacheKey string
err := db.QueryRowContext(t.Context(),
"SELECT cache_key, content_type FROM variant_content",
).Scan(&cacheKey, &storedType)
"SELECT cache_key FROM variant_content",
).Scan(&cacheKey)
if err != nil {
t.Fatalf("variant_content row: %v", err)
}
if storedType != contentType {
t.Errorf("variant_content content_type = %q, want %q",
storedType, contentType)
}
checkFile(t, filepath.Join(stateDir, "cache", "variants",
cacheKey[0:2], cacheKey[2:4], cacheKey), served)
}