From dab708894ed078f2d04ec5f165ab23c1d779da99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 29 May 2024 13:41:03 +0800 Subject: [PATCH] clear cache --- LunaTranslator/LunaTranslator/gui/translatorUI.py | 13 +++++++++++++ .../LunaTranslator/myutils/githubupdate.py | 6 +++++- plugins/shareddllproxy/update.cpp | 9 +++++++++ plugins/winsharedutils/hwnd.cpp | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 270a0758..5743e60f 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -24,6 +24,7 @@ from gui.rangeselect import rangeselct_function from gui.usefulwidget import resizableframeless, isinrect from gui.dialog_savedgame import browserdialog from gui.edittext import edittrans +import shutil class QUnFrameWindow(resizableframeless): @@ -1049,6 +1050,17 @@ class QUnFrameWindow(resizableframeless): button.belong = belong self.buttons[name] = button + def tryremoveuseless(self): + + try: + shutil.rmtree("./cache/temp") + except: + pass + try: + os.remove("./cache/Updater.exe") + except: + pass + def closeEvent(self, a0) -> None: if self.fullscreenmanager: self.fullscreenmanager.endX() @@ -1064,4 +1076,5 @@ class QUnFrameWindow(resizableframeless): saveallconfig() endsubprocs() + self.tryremoveuseless() os._exit(0) diff --git a/LunaTranslator/LunaTranslator/myutils/githubupdate.py b/LunaTranslator/LunaTranslator/myutils/githubupdate.py index 0df1c3d0..65b92595 100644 --- a/LunaTranslator/LunaTranslator/myutils/githubupdate.py +++ b/LunaTranslator/LunaTranslator/myutils/githubupdate.py @@ -72,13 +72,17 @@ def updatemethod(_version, progresscallback): stats = os.stat(savep) if stats.st_size == size: progresscallback( - "总大小{} MB 进度 {}% ".format( + "总大小{} MB 进度 {}% ,正在解压……".format( int(1000 * (int(size / 1024) / 1024)) / 1000, int(10000 * (size / size)) / 100, ), 10000, ) endcallback() + progresscallback( + "准备完毕,等待更新", + 10000, + ) return True return False diff --git a/plugins/shareddllproxy/update.cpp b/plugins/shareddllproxy/update.cpp index 82f8139f..8211f8da 100644 --- a/plugins/shareddllproxy/update.cpp +++ b/plugins/shareddllproxy/update.cpp @@ -32,6 +32,15 @@ int updatewmain(int argc, wchar_t *argv[]) { MessageBoxA(GetForegroundWindow(), (std::string("Update failed!\r\n") + e.what()).c_str(), "Error", 0); ShellExecute(0, L"open", L"https://github.com/HIllya51/LunaTranslator/releases", NULL, NULL, SW_SHOWNORMAL); + return 0; + } + try + { + wcscat(path, L"\\cache\\update"); + std::filesystem::remove_all(path); + } + catch (std::exception &e) + { } return 0; } \ No newline at end of file diff --git a/plugins/winsharedutils/hwnd.cpp b/plugins/winsharedutils/hwnd.cpp index a54a5862..d11ed58a 100644 --- a/plugins/winsharedutils/hwnd.cpp +++ b/plugins/winsharedutils/hwnd.cpp @@ -1,4 +1,4 @@ -#include "define.h" +#include "define.h" DECLARE void showintab(HWND hwnd, bool show) {