asar
asar copied to clipboard
asar.extractFile is Sync
So... I just lost a couple minutes with this and thought it was probably a minor accident or something.
asar.extractFile is not returning a promise or using a callback. I just checked out the imprint of the code and it seems you are calling disk.readFileSync.
(archive, filename) {
const filesystem = disk.readFilesystemSync(archive)
return disk.readFileSync(filesystem, filename, filesystem.getFile(filename))
}
is there a way to call extractFile Asynchronously? Thanks
You can't with the current API, certainly. Given the ASAR format, how feasible is it to even implement?
@malept You'd have to pipe
the file as a stream and read the file from the correct offset as your stream encounters it. Super hard to implement correctly and probably not worth it in the big scheme of things
Humm... i see... could you add this to the docs, then? The javascript API is not really that well documented, and that can lead to some confusion as to how it should be used. It's not really that big a deal for now anyways. Thanks!
We'd be happy to review a pull request to update the API docs for asar.extractFile
.
Cool! I'll look into that when I have some free time next week.
@MarshallOfSound's explanation makes sense - but that leaves me wondering how Electron's fs
can read individual files out of asar files?
Unless I'm crazy, I think I've used fs.copyFileSync
in Electron to copy files out of the asar.