Closed gowy222 closed 3 months ago
should add some fun to fix it before return filePath like:
function fix_path_to_local_env(inputPath) {
if (typeof inputPath !== 'string' || inputPath.length === 0) {
return false;
}
try {
let normalizedPath = path.normalize(inputPath);
let currentOS = process.platform;
if (currentOS === 'win32') {
normalizedPath = normalizedPath.split(path.posix.sep).join(path.win32.sep);
} else {
normalizedPath = normalizedPath.split(path.win32.sep).join(path.posix.sep);
}
return normalizedPath;
} catch (error) {
return false;
}
}
the bug code issued here :
https://github.com/ibrod83/nodejs-file-downloader/blob/master/Download.js#L131 https://github.com/ibrod83/nodejs-file-downloader/blob/master/Download.js#L225
async _shouldSkipRequest() {
if (this.config.fileName && this.config.skipExistingFileName) {
if (await exists(this.config.directory + '/' + this.config.fileName)) {
return true
}
}
return false
}
async _shouldSkipSaving(originalFileName) {
if (this.config.skipExistingFileName && await exists(this.config.directory + '/' + originalFileName)) {
return true;
}
return false;
}
see, shoud NOT use + '/', need use path.join()
Thank you, fixed
as can see in winodws system the result filePath had
/ppocrv4.png
but shouda be\ppocrv4.png