refactor: propagate context into Cache.StoreVariant (noctx)
The size-accounting INSERT in StoreVariant used db.Exec, and StoreVariant took no context at all, so the write was uncancellable and untraceable. Rather than paper over that with context.Background() at the call site, StoreVariant now takes a context.Context and uses ExecContext. The plumbing is small: the only production caller is Service.processAndStore, which already has the request context in scope, so the accounting insert now shares the lifetime of the request that produced the variant. Test callers pass t.Context(). The insert remains best-effort: a failure is logged and the startup and periodic reconciliation passes still adopt any variant file whose accounting row is missing.
This commit is contained in:
@@ -425,7 +425,7 @@ func (s *Service) processAndStore(
|
||||
|
||||
// Store variant to cache
|
||||
err = s.cache.StoreVariant(
|
||||
cacheKey, bytes.NewReader(processedData), processResult.ContentType,
|
||||
ctx, cacheKey, bytes.NewReader(processedData), processResult.ContentType,
|
||||
)
|
||||
if err != nil {
|
||||
s.log.Warn("failed to store variant", "error", err)
|
||||
|
||||
Reference in New Issue
Block a user