electron / get

Download Electron release artifacts
https://npm.im/@electron/get
MIT License
338 stars 106 forks source link

bug: the SHASUMS256.txt download is corrupted with custom filename mirror options set #165

Open ghost opened 4 years ago

ghost commented 4 years ago

When downloading from a mirror and specifying a custom filename, the SHASUMS256.txt is always invalid. When the checksum is downloaded in this case https://github.com/electron/get/blob/9034cc46cb54fabd11d6e540b5093dbbcc7c3a42/src/index.ts#L125-L138 there are two places where the filename used to build the download url can be overwritten by mirror options and corrupt the resulting SHASUMS256.txt file. One is if the mirrorOptions.customFilename is set and the other is if any of the custom_filename env vars are set: https://github.com/electron/get/blob/9034cc46cb54fabd11d6e540b5093dbbcc7c3a42/src/artifact-utils.ts#L61 https://github.com/electron/get/blob/9034cc46cb54fabd11d6e540b5093dbbcc7c3a42/src/artifact-utils.ts#L27-L43 In either case, the default filename for the checksum passed as 'SHASUMS256.txt' gets chosen last after the custom filename and gets overwritten

Can reproduce by setting the mirror var for electron custom filename and trying to get the electron binary via downloadArtifact(). The checksum will error with Error: Could not parse checksum file at line 1: PK as the SHASUMS256.txt is invalid

ophirKatz commented 3 years ago

Hey, did you find a fix for the issue or is it still pending? I'm struggling with it as-well

ghost commented 3 years ago

Hi, I believe this issue is still pending, although I think it could have a quick fix. I was forced to work around it by using custom directory structures only, and no custom filenames