let tempPath = '' // C:\Users\abc\AppData\Local\Temp
let tempFilePath = path.join(tempPath, 'geoip.tar.gz')
let destPath = '' // C:\Users\abc\.config\clash
got
.stream("xxx/GeoLite2-Country.tar.gz")
.pipe(fs.createWriteStream(tempFilePath))
.on("finish", async () => {
let decRes = await decompress(tempFilePath, path.join(destPath, 'Country.mmdb'));
});
I tried set decompress dest path to my destPath directly, and it threw an unknown error. It seems that destPath is hidden on Windows (.config directory).
So I dig up from fs library, a solution is set flag to 'r+'
On Windows, opening an existing hidden file using the 'w' flag (either through fs.open() or fs.writeFile() or fsPromises.open()) will fail with EPERM. Existing hidden files can be opened for writing with the 'r+' flag.
Here is the situation.
I tried set decompress dest path to my destPath directly, and it threw an
unknown error
. It seems that destPath is hidden on Windows (.config directory).So I dig up from fs library, a solution is set flag to 'r+'
So, is there a way to get rid of this extra
decompress_output
directory?