From 7b04f18d4e749e2ae651a4c994d35bca4511fd7b Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 22 Feb 2026 23:39:36 +0800 Subject: [PATCH] =?UTF-8?q?improve:Dlass=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/DlassNoteUploader.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Ink Canvas/Helpers/DlassNoteUploader.cs b/Ink Canvas/Helpers/DlassNoteUploader.cs index 585e0a70..295faf82 100644 --- a/Ink Canvas/Helpers/DlassNoteUploader.cs +++ b/Ink Canvas/Helpers/DlassNoteUploader.cs @@ -221,18 +221,15 @@ namespace Ink_Canvas.Helpers var jsonContent = JsonConvert.SerializeObject(queueData, Formatting.Indented); - // 使用临时文件写入,然后替换,确保原子性 + // 使用进程保护的写入门控,避免安全面板中“进程文件保护”占用导致无法写入 var tempFilePath = queueFilePath + ".tmp"; - File.WriteAllText(tempFilePath, jsonContent); - - // 如果原文件存在,先删除 - if (File.Exists(queueFilePath)) + ProcessProtectionManager.WithWriteAccess(queueFilePath, () => { - File.Delete(queueFilePath); - } - - // 重命名临时文件 - File.Move(tempFilePath, queueFilePath); + File.WriteAllText(tempFilePath, jsonContent); + if (File.Exists(queueFilePath)) + File.Delete(queueFilePath); + File.Move(tempFilePath, queueFilePath); + }); } catch (Exception ex) { @@ -252,10 +249,11 @@ namespace Ink_Canvas.Helpers try { var queueFilePath = GetQueueFilePath(); - if (File.Exists(queueFilePath)) + ProcessProtectionManager.WithWriteAccess(queueFilePath, () => { - File.WriteAllText(queueFilePath, "[]"); - } + if (File.Exists(queueFilePath)) + File.WriteAllText(queueFilePath, "[]"); + }); } catch (Exception ex) {