question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asar.extractFile is Sync

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
MarshallOfSoundcommented, Feb 26, 2019

@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

0reactions
Slapboxcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to unpack an .asar file? - node.js - Stack Overflow
From the asar documentation. (the use of npx here is to avoid to install the asar tool globally with npm install -g asar...
Read more >
Application Packaging · Electron docs gitbook - imfly
An asar archive is a simple tar-like format that concatenates files into a single file. Electron can read arbitrary files from it without...
Read more >
ASAR Archives - Electron
Most fs APIs can read a file or get a file's information from ASAR archives without unpacking, but for some APIs that rely...
Read more >
How to use the asar.extractAll function in asar - Snyk
var extractSlaxFile = function(slaxFileName,slaxAppDir) { try { ensureAppDir(); zipper.sync.unzip(slaxFileName).save(slaxAppDir); } catch (e) { console.log("The ...
Read more >
Application Packaging | Electron
An asar archive is a simple tar-like format that concatenates files into a single file. Electron can read arbitrary files from it without...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found