From 8fb72b4a1473a1e382d5d962666b3b95e5a5d360 Mon Sep 17 00:00:00 2001 From: kookxiang Date: Sun, 1 Dec 2024 17:25:50 +0800 Subject: [PATCH] fix archive updating (#174) --- Jellyfin.Plugin.Bangumi/Archive/ArchiveController.cs | 3 +++ .../Archive/Relation/SubjectEpisodeRelation.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Jellyfin.Plugin.Bangumi/Archive/ArchiveController.cs b/Jellyfin.Plugin.Bangumi/Archive/ArchiveController.cs index ee777fb..bc2c0b5 100644 --- a/Jellyfin.Plugin.Bangumi/Archive/ArchiveController.cs +++ b/Jellyfin.Plugin.Bangumi/Archive/ArchiveController.cs @@ -19,6 +19,9 @@ public class OAuthController(ArchiveData archive) DateTime? lastModifyTime = null; var directory = new DirectoryInfo(archive.BasePath); + if (!directory.Exists) + return []; + foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories)) { if (lastModifyTime == null) diff --git a/Jellyfin.Plugin.Bangumi/Archive/Relation/SubjectEpisodeRelation.cs b/Jellyfin.Plugin.Bangumi/Archive/Relation/SubjectEpisodeRelation.cs index 7b0fd45..a5ee8d7 100644 --- a/Jellyfin.Plugin.Bangumi/Archive/Relation/SubjectEpisodeRelation.cs +++ b/Jellyfin.Plugin.Bangumi/Archive/Relation/SubjectEpisodeRelation.cs @@ -85,6 +85,10 @@ private async Task Save() writer.Flush(); await outStream.FlushAsync(); + outStream.Close(); + + if (File.Exists(FilePath)) + File.Move(FilePath, Path.Join(archive.TempPath, Path.GetRandomFileName()), true); File.Move(tempFilePath, FilePath, true); } } \ No newline at end of file