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:
parent
650e5f5e30
commit
ed8f41bd4a
17 changed files with 5636 additions and 65 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue