feat: refund tracked storage usage on deletion and replacement

Persist per-file storage receipts, preserve refundability on rename, account for PDF replacements and permit deletion at the consumption limit. Update CGU, installation documentation and regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-11-08 05:40:08 +00:00
commit ed8f41bd4a
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
17 changed files with 5636 additions and 65 deletions

View file

@ -159,7 +159,6 @@ namespace Yavsc.ApiControllers
uid,
User.Identity?.Name ?? uid,
cpuSeconds: (decimal)stopwatch.Elapsed.TotalSeconds,
storageBytes: fo.Length,
actorUserId: uid);
return File(fo.OpenRead(), "application/pdf");
@ -185,12 +184,21 @@ namespace Yavsc.ApiControllers
uid,
User.Identity?.Name ?? uid,
cpuSeconds: (decimal)stopwatch.Elapsed.TotalSeconds,
storageBytes: renderedPdf?.Length ?? 0,
actorUserId: uid);
logger.LogError(ex, "estimate {QueryId}: TeX/PDF render failed", queryId);
return Problem("TeX render failed: " + ex.Message);
}
finally
{
if (renderedPdf is not null)
{
renderedPdf.Refresh();
if (renderedPdf.Exists)
await ResourceUsageTracker.RecordStorageAsync(dbContext, uid, User.Identity?.Name ?? uid,
"pdf/" + renderedPdf.FullName, renderedPdf.Length, CancellationToken.None);
}
}
}
// Loads the estimate linked to a query with the navigation the