Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asar.extractFile is Sync #167

Open
thiagorova opened this issue Feb 26, 2019 · 6 comments
Open

asar.extractFile is Sync #167

thiagorova opened this issue Feb 26, 2019 · 6 comments

Comments

@thiagorova
Copy link

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

@malept
Copy link
Member

malept commented Feb 26, 2019

You can't with the current API, certainly. Given the ASAR format, how feasible is it to even implement?

@MarshallOfSound
Copy link
Member

@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

@thiagorova
Copy link
Author

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!

@malept
Copy link
Member

malept commented Feb 27, 2019

We'd be happy to review a pull request to update the API docs for asar.extractFile.

@thiagorova
Copy link
Author

Cool! I'll look into that when I have some free time next week.

@Nantris
Copy link

Nantris commented Mar 3, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants