Skip to content

The only downloader you need. 下载器的集大成者。

fix(updater): Windows 短路径启动错误版本 & macOS DMG 残留挂载

XiaoYouChR86ad5d38589c
diff --git a/app/services/update_service.py b/app/services/update_service.py
index b57b506a..0bada190 100644
--- a/app/services/update_service.py
+++ b/app/services/update_service.py
@@ -49,6 +49,12 @@ def extractTarXz(archivePath: Path, targetDir: Path) -> None:
async def extractDmg(dmgPath: Path, targetDir: Path) -> None:
mountPoint = dmgPath.parent / "_dmg_mount"
+ if mountPoint.exists():
+ await asyncio.create_subprocess_exec(
+ "hdiutil", "detach", str(mountPoint), "-force", "-quiet",
+ stdout=asyncio.subprocess.DEVNULL, stderr=asyncio.subprocess.DEVNULL,
+ )
+ shutil.rmtree(mountPoint, ignore_errors=True)
mountPoint.mkdir(exist_ok=True)
try:
proc = await asyncio.create_subprocess_exec(
@@ -67,11 +73,10 @@ async def extractDmg(dmgPath: Path, targetDir: Path) -> None:
await asyncio.to_thread(shutil.copytree, apps[0], targetDir, symlinks=True)
finally:
await asyncio.create_subprocess_exec(
- "hdiutil", "detach", str(mountPoint), "-quiet",
+ "hdiutil", "detach", str(mountPoint), "-force", "-quiet",
stdout=asyncio.subprocess.DEVNULL, stderr=asyncio.subprocess.DEVNULL,
)
- if mountPoint.exists():
- mountPoint.rmdir()
+ shutil.rmtree(mountPoint, ignore_errors=True)
def installPendingPacks(featuresDir: Path) -> None:
@@ -290,7 +295,8 @@ class UpdateService(QObject):
patchPath = STAGING_DIR / "patch.hdiff"
stagingNewDir = STAGING_DIR / "app_new"
- args = [str(updaterPath), str(os.getpid()), str(appDir), sys.executable]
+ args = [str(updaterPath), str(os.getpid()), str(appDir),
+ str(Path(sys.executable).resolve())]
if patchPath.is_file():
args.append(str(patchPath))
elif stagingNewDir.is_dir():
diff --git a/tools/updater/updater.c b/tools/updater/updater.c
index 8d15057d..a64ec5e5 100644
--- a/tools/updater/updater.c
+++ b/tools/updater/updater.c
@@ -867,6 +867,10 @@ int main(int argc, char *argv[]) {
const wchar_t *appDir = wargv[2];
const wchar_t *appExe = wargv[3];
const wchar_t *patchFile = wargc >= 5 ? wargv[4] : NULL;
+
+ wchar_t longAppExe[PATH_BUF];
+ if (GetLongPathNameW(appExe, longAppExe, PATH_BUF))
+ appExe = longAppExe;
#else
unsigned long appPid = strtoul(argv[1], NULL, 10);
const char *appDir = argv[2];