fix: an update interrupted during download was blocking future updates

Massimo Melina committed Mar 15, 2026 at 21:44 UTC 8bc9557455da88320c0e58dc990fbd2933788715
1 file changed +5 -2
src/update.ts
+5 -2
@@ -134,13 +134,16 @@ export async function update(tagOrUrl: string='') {
134 }
135 if (url) {
136 console.log("downloading", url)
137 + const temp = LOCAL_UPDATE + '-temp'
138 + await rm(temp, { force: true })
139 try {
138 - await writeFile(LOCAL_UPDATE, await httpStream(url))
140 + await writeFile(temp, await httpStream(url))
141 }
142 catch(e: any) {
141 - await rm(LOCAL_UPDATE).catch(() => {}) // no leftovers
143 + await rm(temp).catch(() => {}) // no leftovers
144 throw "Download failed for " + url + prefix(' – ', e?.message)
145 }
146 + await rename(temp, LOCAL_UPDATE)
147 console.debug("download finished")
148 }
149 const bin = process.execPath