Closing asar


With Electron having patched the fs modules to support the ability to read into an asar, I’m using that to currently obfuscate a file structure and provide the user with a single output file for a process. The issue I’m currently running into though is that… when I open the asar file for the user, the file I opened is “locked” until I reload the UI or restart the app. I’m not 100% sure on this yet but I’m wondering if the read functions should be attempting to close the files using the file descriptors. Outside of that, I’m not 100% sure how to handle this. Is there a way I’m not familiar with or don’t have documented that will allow us to “close” an asar if I’ve been reading it?


In case someone else comes across this…

From what I’ve gathered in continued reading it seems that asar packages weren’t intended to do what I wanted to do with them (using them as a single file storage that I can read into within having to unwrap the whole thing). Once an asar is opened and read into, that process locks the asar file until the UI is reloaded or the application is restarted.

This solution seemed like such an elegant way to do what I wanted though so I kept digging. In the end I ended up working out a way to release the lock on the asar. To do so, open the asar in a child window. The lock is bound to the process that opened it. If you open the asar in a child window and then close that child window, it releases the lock on the asar.