Skip to content

Commit 49e4799

Browse files
committed
Generate stable name when not using filename
Currently it uses the URL which creates invalid paths like /pending/temp-http:/myurl.com/latest
1 parent 7367f2e commit 49e4799

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/electron-updater/src/AppUpdater.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
BlockMap,
1313
retry,
1414
} from "builder-util-runtime"
15-
import { randomBytes } from "crypto"
15+
import { randomBytes, createHash } from "crypto"
1616
import { release } from "os"
1717
import { EventEmitter } from "events"
1818
import { mkdir, outputFile, readFile, rename, unlink } from "fs-extra"
@@ -698,11 +698,13 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
698698
function getCacheUpdateFileName(): string {
699699
// NodeJS URL doesn't decode automatically
700700
const urlPath = decodeURIComponent(taskOptions.fileInfo.url.pathname)
701-
if (urlPath.endsWith(`.${taskOptions.fileExtension}`)) {
701+
if (urlPath.toLowerCase().endsWith(`.${taskOptions.fileExtension.toLowerCase()}`)) {
702702
return path.basename(urlPath)
703703
} else {
704-
// url like /latest, generate name
705-
return taskOptions.fileInfo.info.url
704+
// url like /latest, generate stable name
705+
const hash = createHash("sha1")
706+
hash.update(taskOptions.fileInfo.url.toString())
707+
return hash.digest("hex")
706708
}
707709
}
708710

0 commit comments

Comments
 (0)