Repository navigation
Closed
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- v7.1.4
- Operating System:
- Windows 10 (1803)
- Last Known Working Electron version:
- I'm not sure, because the reason for the error, as described later, is the path resolution error
Expected Behavior
Can normally install with CacheActual Behavior
Download times are long and installation failures are common, and throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')To Reproduce
private getCachePath(url: string, fileName: string): string { //const sanitizedUrl = sanitize(url);
return path.resolve(this.cacheRoot, /*sanitizedUrl,*/ fileName);
}
After the modification in the above function, you can install with the Cache path successfully
Screenshots
Additional Information
Recently, when upgrading to version 7.1.4, I encountered a problem that cannot be solved with caching. What's the problem?
After research, it is found that the path error is caused by the process of verifying whether there are cache files in the cache during the download process:
- Since electron/get v1.4.0, the getCachePath function has been added to the sanitize-filename package. See before and after:
1.1 v1.4.0
Private getCachePath(fileName: string): string {
Return path. Resolve (enclosing cacheRoot, fileName);
}
1.1 v1.5.0
Private getCachePath(url: string, fileName: string): string {
Const sanitizedUrl = sanitize (url);
Return path. Resolve (enclosing cacheRoot, sanitizedUrl, fileName);
} - Add sanitize-filename package, the resolved cache path, has been safely invalidated, the following is the package's function description:
The Details
Sanitize - filename removes the following:
Control characters (0x00 -- 0x1f and 0x80 -- 0x9f)
Reserved characters (/,?, <, >, , :, *, |, and ")
Unix reserved filenames (. And..)
Trailing times and Spaces (for Windows)
Windows reserved filenames (CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9)
The resulting string is truncated to 255 bytes in length. The string will not contain any directory paths and will be safe to use as a filename. - As a result, the subsequent function, which verifies whether the downloaded file already exists in the cache, fails to return forever
Activity
electron-triage commentedon Mar 9, 2021
The Electron version reported on this issue is no longer supported. See our supported versions documentation.
If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.
Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.