From b722ab600627a8872cc6803bfb824be417650459 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Sat, 29 Oct 2022 22:03:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/Bootstrapper.cs | 28 +++++++++++++++++++ .../ViewModels/VersionUpdateViewModel.cs | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/MeoAsstGui/Bootstrapper.cs b/src/MeoAsstGui/Bootstrapper.cs index 5354121c31..cd932796c8 100644 --- a/src/MeoAsstGui/Bootstrapper.cs +++ b/src/MeoAsstGui/Bootstrapper.cs @@ -78,6 +78,34 @@ namespace MeoAsstGui } } + // TODO: Delete this + // 由于 zzyyyl 的失误,v4.6.5-beta.3 之后的版本会在更新时删除 Paddle,在发正式版后将下面的块删掉 + // 恢复被删除的 Paddle + { + string resourceDir = Directory.GetCurrentDirectory() + "\\resource"; + string oldResourceDir = Directory.GetCurrentDirectory() + "\\resource.old"; + + var paddleResourcePaths = new[] + { + "\\PaddleOCR", + "\\PaddleCharOCR", + "\\global\\txwy\\resource\\PaddleOCR", + "\\global\\YoStarEN\\resource\\PaddleOCR", + "\\global\\YoStarJP\\resource\\PaddleOCR", + "\\global\\YoStarKR\\resource\\PaddleOCR", + }; + + foreach (var path in paddleResourcePaths) + { + string paddleDir = resourceDir + path; + string oldPaddleDir = oldResourceDir + path; + if (Directory.Exists(oldPaddleDir) && !Directory.Exists(paddleDir)) + { + VersionUpdateViewModel.CopyFilesRecursively(oldPaddleDir, paddleDir); + } + } + } + base.OnStart(); ViewStatusStorage.Load(); Localization.Load(); diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 40613fef9c..2a9f925ab1 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -243,7 +243,7 @@ namespace MeoAsstGui { string paddleDir = resourceDir + path; string oldPaddleDir = oldResourceDir + path; - if (Directory.Exists(paddleDir)) + if (Directory.Exists(oldPaddleDir)) { CopyFilesRecursively(oldPaddleDir, paddleDir); } @@ -891,7 +891,7 @@ namespace MeoAsstGui /// /// 源文件夹 /// 目标文件夹 - private static void CopyFilesRecursively(string sourcePath, string targetPath) + public static void CopyFilesRecursively(string sourcePath, string targetPath) { Directory.CreateDirectory(targetPath);