diff --git a/DysonNetwork.Sphere/Storage/FileService.ReferenceMigration.cs b/DysonNetwork.Sphere/Storage/FileService.ReferenceMigration.cs index 0459e93..f6b3933 100644 --- a/DysonNetwork.Sphere/Storage/FileService.ReferenceMigration.cs +++ b/DysonNetwork.Sphere/Storage/FileService.ReferenceMigration.cs @@ -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();