🐛 Fix migrate has no value

This commit is contained in:
LittleSheep 2025-06-02 20:52:03 +08:00
parent 2691c5d9ac
commit 5487b4e607

View File

@ -43,16 +43,18 @@ public class FileReferenceMigrationService(AppDatabase db)
.ToDictionary(g => g.Key, g => g.ToList());
var fileReferences = posts.SelectMany(post =>
attachmentsDict[post.Id].Select(attachment =>
new CloudFileReference
{
FileId = attachment.Id,
File = attachment,
Usage = "post",
ResourceId = post.Id.ToString(),
CreatedAt = SystemClock.Instance.GetCurrentInstant(),
UpdatedAt = SystemClock.Instance.GetCurrentInstant()
})
attachmentsDict.TryGetValue(post.Id, out var value)
? value.Select(attachment =>
new CloudFileReference
{
FileId = attachment.Id,
File = attachment,
Usage = "post",
ResourceId = post.Id.ToString(),
CreatedAt = SystemClock.Instance.GetCurrentInstant(),
UpdatedAt = SystemClock.Instance.GetCurrentInstant()
})
: []
)
.ToList();