From 5487b4e607727ecab239094a29643ae659cddfeb Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 2 Jun 2025 20:52:03 +0800 Subject: [PATCH] :bug: Fix migrate has no value --- .../Storage/FileService.ReferenceMigration.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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();