Now the migration helps recreate mis-references post attachments

This commit is contained in:
2025-06-02 20:29:03 +08:00
parent 782cf56927
commit 0550c4f6de
2 changed files with 40 additions and 60 deletions

View File

@ -25,11 +25,9 @@ public class FileReferenceService(AppDatabase db, FileService fileService, ICach
Duration? duration = null)
{
// Calculate expiration time if needed
Instant? finalExpiration = expiredAt;
var finalExpiration = expiredAt;
if (duration.HasValue)
{
finalExpiration = SystemClock.Instance.GetCurrentInstant() + duration.Value;
}
var reference = new CloudFileReference
{
@ -42,8 +40,6 @@ public class FileReferenceService(AppDatabase db, FileService fileService, ICach
db.FileReferences.Add(reference);
await db.SaveChangesAsync();
// Purge cache for the file since its usage count has effectively changed
await fileService._PurgeCacheAsync(fileId);
return reference;