From 82dbe28b5e50368d26ab6651ecb0c2e99d7a0926 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Mon, 12 May 2025 19:42:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20cache=20=E7=A7=BB=E5=8A=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/AsstProxy.cs | 31 +++++++++++++++++++++----- src/MaaWpfGui/Services/StageManager.cs | 1 - 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 5047682c6b..3f07503fbb 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -260,7 +260,6 @@ namespace MaaWpfGui.Main string mainCache = Directory.GetCurrentDirectory() + @"\cache"; string globalCache = mainCache + @"\resource\global\" + clientType; - bool loaded; if (clientType is "" or "Official" or "Bilibili") { @@ -270,7 +269,8 @@ namespace MaaWpfGui.Main loaded &= LoadResIfExists(mainCache); } else - {// Read resources first, then read cache + { + // Read resources first, then read cache MoveTasks(mainCache); MoveTasks(globalCache); loaded = LoadResIfExists(mainRes) && LoadResIfExists(mainCache); @@ -293,12 +293,33 @@ namespace MaaWpfGui.Main } static void MoveTasks(string oldPath) - { // 铲资源更新的屎 - if (!Directory.Exists(oldPath + @"\resource\tasks.json")) + { + try { - File.Move(oldPath + @"\resource\tasks.json", oldPath + @"\resource\tasks\tasks.json", true); + string tasksJsonPath = Path.Combine(oldPath, @"resource\tasks.json"); + string tasksFolderPath = Path.Combine(oldPath, @"resource\tasks"); + string newTasksJsonPath = Path.Combine(tasksFolderPath, "tasks.json"); + + if (!File.Exists(tasksJsonPath)) + { + return; + } + + if (!Directory.Exists(tasksFolderPath)) + { + Directory.CreateDirectory(tasksFolderPath); + _logger.Information($"Created directory: {tasksFolderPath}"); + } + + File.Move(tasksJsonPath, newTasksJsonPath, true); + _logger.Information($"Moved {tasksJsonPath} to {newTasksJsonPath}"); + } + catch (Exception ex) + { + _logger.Error($"Failed to move tasks.json: {ex.Message}"); } } + } /// diff --git a/src/MaaWpfGui/Services/StageManager.cs b/src/MaaWpfGui/Services/StageManager.cs index d697023a99..bce3746402 100644 --- a/src/MaaWpfGui/Services/StageManager.cs +++ b/src/MaaWpfGui/Services/StageManager.cs @@ -62,7 +62,6 @@ namespace MaaWpfGui.Services public async Task UpdateStageWeb() { - if (!await CheckWebUpdate()) { return;