Skip to content

Commit 32f603d

Browse files
committed
fix updater config file path and debug check
1 parent 5d0d9bb commit 32f603d

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

app/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def main(enable_updater: bool = True):
3636
updater.is_enable = enable_updater
3737

3838
# override updater config
39-
config_file = paths.update_dir.join("updater.json")
40-
if os.getenv("DEBUG", "0") == 1 and config_file.exists() and config_file.is_file():
39+
config_file = paths.update_dir / "updater.json"
40+
if os.getenv("DEBUG", "0") == "1" and config_file.exists() and config_file.is_file():
4141
updater.load_from_file_and_override(config_file)
4242

4343
# check if the app is already running

app/builtin/github_updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ async def fetch(self):
6969
r.raise_for_status()
7070

7171
paths = AppPaths()
72-
self.filename = f"{paths.update_tmp}/{package_name}"
72+
self.filename = f"{paths.update_dir}/{package_name}"

app/builtin/gitlab_updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ async def fetch(self):
8585

8686
path = urlparse(self.download_url).path
8787
paths = AppPaths()
88-
self.filename = f"{paths.update_tmp}/{os.path.basename(path)}"
88+
self.filename = f"{paths.update_dir}/{os.path.basename(path)}"

app/builtin/paths.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from singleton_decorator import singleton
33
from PySide6.QtCore import QStandardPaths, QCoreApplication
44

5+
56
@singleton
67
class AppPaths:
78
base_dir: Path
@@ -12,11 +13,15 @@ def __init__(self, *, base_dir=None):
1213
app = QCoreApplication.instance()
1314
if app is None:
1415
raise RuntimeError("QCoreApplication instance is not created yet.")
15-
self.base_dir = Path(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppDataLocation))
16+
self.base_dir = Path(
17+
QStandardPaths.writableLocation(
18+
QStandardPaths.StandardLocation.AppDataLocation
19+
)
20+
)
1621
else:
1722
self.base_dir = base_dir
1823

19-
self.update_dir = self.base_dir / "update_tmp"
24+
self.update_dir = self.base_dir / "update"
2025

2126
self.base_dir.mkdir(parents=True, exist_ok=True)
2227
self.update_dir.mkdir(parents=True, exist_ok=True)

app/builtin/update.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def apply_update():
150150
pid = os.getpid()
151151
paths = AppPaths()
152152
if sys.platform == "darwin":
153-
new_executable_name = f"{paths.update_tmp}/{cfg.APP_NAME}.app"
153+
new_executable_name = f"{paths.update_dir}/{cfg.APP_NAME}.app"
154154
subprocess.Popen(
155155
[
156156
"open",
@@ -164,11 +164,11 @@ def apply_update():
164164
],
165165
preexec_fn=os.setpgrp,
166166
env=os.environ.copy(),
167-
cwd=paths.update_tmp,
167+
cwd=paths.update_dir,
168168
)
169169
elif sys.platform == "linux":
170-
new_executable_name = Path(f"{paths.update_tmp}/{cfg.APP_NAME}")
171-
work_dir = Path(f"{paths.update_tmp}")
170+
new_executable_name = Path(f"{paths.update_dir}/{cfg.APP_NAME}")
171+
work_dir = Path(f"{paths.update_dir}")
172172
if new_executable_name.is_dir():
173173
# Onedir
174174
work_dir = new_executable_name
@@ -187,11 +187,11 @@ def apply_update():
187187
cwd=work_dir,
188188
)
189189
else: # win32
190-
new_executable_name = Path(f"{paths.update_tmp}/{cfg.APP_NAME}")
190+
new_executable_name = Path(f"{paths.update_dir}/{cfg.APP_NAME}")
191191
new_executable_name_with_exe = Path(
192-
f"{paths.update_tmp}/{cfg.APP_NAME}.exe"
192+
f"{paths.update_dir}/{cfg.APP_NAME}.exe"
193193
)
194-
work_dir = Path(f"{paths.update_tmp}")
194+
work_dir = Path(f"{paths.update_dir}")
195195
if new_executable_name.is_dir():
196196
# Onedir
197197
work_dir = new_executable_name
@@ -308,7 +308,7 @@ def clean_old_package():
308308

309309
# Remove files in package_dir
310310
paths = AppPaths()
311-
package_dir = paths.update_tmp
311+
package_dir = paths.update_dir
312312
if package_dir.exists() and package_dir.is_dir():
313313
for entry in os.scandir(package_dir):
314314
entry_path = Path(entry.path)

0 commit comments

Comments
 (0)