@samitouri / QOSami-HFS / commits / ada78a8c

fix: update not working if you launch new-hfs.exe #829

Massimo Melina committed Dec 11, 2024 at 22:53 UTC ada78a8c6d6fa4e22c47c7ec2b1b121b7bf15c17
1 file changed +4 -2
src/update.ts
+4 -2
@@ -5,7 +5,7 @@ import { ARGS_FILE, argv, HFS_REPO, IS_BINARY, IS_WINDOWS, RUNNING_BETA } from '
5 import { dirname, join } from 'path'
6 import { spawn, spawnSync } from 'child_process'
7 import { DAY, exists, debounceAsync, httpStream, unzip, prefix, xlate, HOUR } from './misc'
8 -import { createReadStream, renameSync, unlinkSync, writeFileSync } from 'fs'
8 +import { createReadStream, existsSync, renameSync, unlinkSync, writeFileSync } from 'fs'
9 import { pluginsWatcher } from './plugins'
10 import { chmod, stat } from 'fs/promises'
11 import { Readable } from 'stream'
@@ -130,7 +130,9 @@ export async function update(tagOrUrl: string='') {
130 const bin = process.execPath
131 const binPath = dirname(bin)
132 const binFile = 'hfs' + (IS_WINDOWS ? '.exe' : '') // currently running bin could have been renamed
133 - const newBinFile = 'new-' + binFile
133 + let newBinFile = binFile
134 + do { newBinFile = 'new-' + newBinFile }
135 + while (existsSync(join(binPath, newBinFile)))
136 pluginsWatcher.pause()
137 try {
138 await unzip(updateSource, path =>