clear cache

This commit is contained in:
恍兮惚兮 2024-05-29 13:41:03 +08:00
parent 6d88c762ac
commit dab708894e
4 changed files with 28 additions and 2 deletions

View File

@ -24,6 +24,7 @@ from gui.rangeselect import rangeselct_function
from gui.usefulwidget import resizableframeless, isinrect from gui.usefulwidget import resizableframeless, isinrect
from gui.dialog_savedgame import browserdialog from gui.dialog_savedgame import browserdialog
from gui.edittext import edittrans from gui.edittext import edittrans
import shutil
class QUnFrameWindow(resizableframeless): class QUnFrameWindow(resizableframeless):
@ -1049,6 +1050,17 @@ class QUnFrameWindow(resizableframeless):
button.belong = belong button.belong = belong
self.buttons[name] = button 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: def closeEvent(self, a0) -> None:
if self.fullscreenmanager: if self.fullscreenmanager:
self.fullscreenmanager.endX() self.fullscreenmanager.endX()
@ -1064,4 +1076,5 @@ class QUnFrameWindow(resizableframeless):
saveallconfig() saveallconfig()
endsubprocs() endsubprocs()
self.tryremoveuseless()
os._exit(0) os._exit(0)

View File

@ -72,13 +72,17 @@ def updatemethod(_version, progresscallback):
stats = os.stat(savep) stats = os.stat(savep)
if stats.st_size == size: if stats.st_size == size:
progresscallback( progresscallback(
"总大小{} MB 进度 {}% ".format( "总大小{} MB 进度 {}% ,正在解压……".format(
int(1000 * (int(size / 1024) / 1024)) / 1000, int(1000 * (int(size / 1024) / 1024)) / 1000,
int(10000 * (size / size)) / 100, int(10000 * (size / size)) / 100,
), ),
10000, 10000,
) )
endcallback() endcallback()
progresscallback(
"准备完毕,等待更新",
10000,
)
return True return True
return False return False

View File

@ -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); 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); 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; return 0;
} }

View File

@ -1,4 +1,4 @@
#include "define.h" #include "define.h"
DECLARE void showintab(HWND hwnd, bool show) DECLARE void showintab(HWND hwnd, bool show)
{ {