From 2f27ae3464222fa90c184b9e88371e8e21354369 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Wed, 1 Nov 2023 06:00:51 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20installer=20:=20update?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AE=E3=83=91=E3=82=B9=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- batch/restart.bat | 7 ++++--- batch/update.bat | 14 +++++++------- model.py | 6 ++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/batch/restart.bat b/batch/restart.bat index e02b64a0..b6e9b03b 100644 --- a/batch/restart.bat +++ b/batch/restart.bat @@ -1,8 +1,9 @@ @if not "%~0"=="%~dp0.\%~nx0" start /min cmd /c,"%~dp0.\%~nx0" %* & goto :eof set name=%1 -set path=%~dp0 +set local_path=%~dp0 taskkill /im %name% /F - -START "" %path%/%name% \ No newline at end of file +ping -n 2 127.0.0.1 > nul +START "" %local_path%%name% +del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/batch/update.bat b/batch/update.bat index 4bc2e679..e0e83855 100644 --- a/batch/update.bat +++ b/batch/update.bat @@ -4,17 +4,17 @@ set exe_name=%1 set folder_name=%2 set folder_tmp=%3 set restart=%4 -set path=%~dp0 +set local_path=%~dp0 taskkill /im %exe_name% /F ping -n 2 127.0.0.1 > nul -del /f %exe_name% -rmdir /s /q %folder_name% -move /Y %exe_tmp_name%\* .\ -rmdir /s /q %exe_tmp_name% +del /f %local_path%%exe_name% +rmdir /s /q %local_path%%folder_name% +xcopy %local_path%%folder_tmp% %local_path% /E /I +rmdir /s /q %local_path%%folder_tmp% if %restart% == True ( - START "" %path%/%exe_name% + START "" %local_path%%exe_name% ) - +pause del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/model.py b/model.py index f79c4dfc..ab5f49ce 100644 --- a/model.py +++ b/model.py @@ -3,6 +3,7 @@ from zipfile import ZipFile from subprocess import Popen, PIPE from os import makedirs as os_makedirs from os import path as os_path +from os import remove as os_remove from shutil import rmtree, move from datetime import datetime from logging import getLogger, FileHandler, Formatter, INFO @@ -284,6 +285,7 @@ class Model: file.write(chunk) with ZipFile(os_path.join(current_directory, tmp_directory_name, filename)) as zf: zf.extractall(os_path.join(current_directory, tmp_directory_name)) + os_remove(os_path.join(current_directory, tmp_directory_name, filename)) move(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)] Popen(command, cwd=current_directory) @@ -297,8 +299,8 @@ class Model: folder_name = '_internal' batch_name = 'restart.bat' current_directory = config.LOCAL_PATH - - command = [os_path.join(current_directory, folder_name, "batch", batch_name), program_name] + move(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) + command = [os_path.join(current_directory, batch_name), program_name] Popen(command, cwd=current_directory) @staticmethod