From ba2f2d5708ebf4cb0ff23ba814129dca0519370e Mon Sep 17 00:00:00 2001 From: Lightczx <1686188646@qq.com> Date: Mon, 1 May 2023 10:29:11 +0800 Subject: [PATCH] fix gacha fetch --- .../Snap.Hutao/Service/GachaLog/GachaLogFetchContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/GachaLogFetchContext.cs b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/GachaLogFetchContext.cs index 1b05746b..072a4b77 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/GachaLogFetchContext.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/GachaLogFetchContext.cs @@ -145,8 +145,13 @@ internal struct GachaLogFetchContext using (IServiceScope scope = serviceProvider.CreateScope()) { AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService(); - GachaItemSaveContext saveContext = new(ItemsToAdd, isLazy, QueryOptions.EndId, appDbContext.GachaItems); - TargetArchive!.SaveItems(saveContext); + + // While no item is fetched, archive can be null. + if (TargetArchive != null) + { + GachaItemSaveContext saveContext = new(ItemsToAdd, isLazy, QueryOptions.EndId, appDbContext.GachaItems); + TargetArchive.SaveItems(saveContext); + } } }