Keep the content type a store put in memory over one read from disk (closes #70)
check / check (push) Successful in 3m31s

GetVariant now adds the content type it read from a .meta file only
when memory holds none for the variant, so a type StoreVariant added
meanwhile is not replaced. A read that found no .meta file yet still
gets application/octet-stream for that one request, as before this
change, but no longer leaves it in memory for later hits.

Model: opus-5-5
This commit is contained in:
2026-09-29 07:29:52 +00:00
parent fc87c2117d
commit 7f358602e4
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -522,7 +522,10 @@ func (c *Cache) IncrementTransformCount(ctx context.Context) {
// loadVariantWithMeta is GetVariant for a variant metaCache does not
// hold: it reads the content type from the variant's .meta file and
// keeps it in metaCache.
// keeps it in metaCache, unless a StoreVariant has put one there
// meanwhile. The stored one wins, since this read may have found the
// variant file before the store wrote the .meta file, and so got
// application/octet-stream.
func (c *Cache) loadVariantWithMeta(
cacheKey VariantKey,
) (io.ReadCloser, int64, string, error) {
@@ -531,7 +534,7 @@ func (c *Cache) loadVariantWithMeta(
return nil, 0, "", err
}
c.metaCache.Add(cacheKey, contentType)
c.metaCache.ContainsOrAdd(cacheKey, contentType)
return reader, size, contentType, nil
}