@samitouri / QOSami-HFS / commits / 90524cd2

fix: admin/home: wrong message installing an update #1037

Massimo Melina committed Jul 5, 2025 at 11:18 UTC 90524cd2ae966d36096ba9abf525c160250d44d8
1 file changed +8 -5
src/update.ts
+8 -5
@@ -101,11 +101,14 @@ export function previousAvailable() {
101 }
102
103 export async function updateSupported() {
104 - return process.env.DISABLE_UPDATE ? false : (argv.forceupdate || IS_BINARY && !await RUNNING_AS_SERVICE)
104 + return !process.env.DISABLE_UPDATE && (argv.forceupdate || IS_BINARY && !await RUNNING_AS_SERVICE)
105 }
106
107 export async function update(tagOrUrl: string='') {
108 - if (!await updateSupported()) throw "only binary versions supports automatic update for now"
108 + if (!await updateSupported())
109 + throw process.env.DISABLE_UPDATE ? "Automatic updates are disabled"
110 + : !IS_BINARY ? "Only binary versions support automatic updates"
111 + : "Automatic updates are not available running as a service"
112 let url = tagOrUrl.includes('://') && tagOrUrl
113 if (tagOrUrl === PREVIOUS_TAG)
114 await rename(PREVIOUS_FN, LOCAL_UPDATE)
@@ -118,21 +121,21 @@ export async function update(tagOrUrl: string='') {
121 else throw e
122 }) as Release | undefined
123 if (!update)
121 - throw "update not found"
124 + throw "Update not found"
125 const plat = '-' + xlate(process.platform, { win32: 'windows', darwin: 'mac' })
126 const assetSearch = `${plat}-${process.arch}`
127 const legacyAssetSearch = `${plat}${prefix('-', xlate(process.arch, { x64: '', arm64: 'arm' }))}.zip` // legacy pre-0.53.0-rc16
128 const asset = update.assets.find((x: any) => x.name.includes(assetSearch) && x.name.endsWith('.zip'))
129 || update.assets.find((x: any) => x.name.endsWith(legacyAssetSearch))
130 if (!asset)
128 - throw `asset not found: ${assetSearch}`
131 + throw `Asset not found: ${assetSearch}`
132 url = asset.browser_download_url
133 }
134 if (url) {
135 console.log("downloading", url)
136 const { body } = await httpWithBody(url)
137 if (!body)
135 - throw "download failed for " + url
138 + throw "Download failed for " + url
139 await writeFile(LOCAL_UPDATE, body)
140 }
141 const bin = process.execPath