You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to close the fd of an .asar we're using #3949
On Windows, I use my own auto-update framework which is supposed to replace the .asar file of an app. This works fine for Linux, OS X, but it requires a hack for Windows with an external script doing the work, because Electron keeps the .asar file open at all times.
What I'm asking is a way to close any asar files programatically we've used in Electron, therefore allowing to move them/delete them on Windows.
The cleanest way I can think of is to add a clearCachedAsarArchive method to the process object, which calls destroy() for the archive and clears it from the cachedArchives. So it will unlock the file, and your app will continue to work if you want to read it later.
@zcbenz This sounds reasonable, but would it destroy all archives? Since reading another file would open it again and work, I don't see anything bad about cleaning all archives, it's OK.
What concerns me is that .destroy() doesn't seem to call fs.close on the fd (.getFD()). Am I wrong?
@Ivshti You need to add a _close call in Archive::~Archive for Windows, for POSIX the fd is destroyed automatically, I forgot to do the same for Windows.
To close a file opened with _open_osfhandle, call _close. The underlying handle is also closed by a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle.
Activity
zcbenz commentedon Dec 31, 2015
The cleanest way I can think of is to add a
clearCachedAsarArchivemethod to theprocessobject, which callsdestroy()for the archive and clears it from thecachedArchives. So it will unlock the file, and your app will continue to work if you want to read it later.Ivshti commentedon Dec 31, 2015
@zcbenz This sounds reasonable, but would it destroy all archives? Since reading another file would open it again and work, I don't see anything bad about cleaning all archives, it's OK.
What concerns me is that
.destroy()doesn't seem to callfs.closeon the fd (.getFD()). Am I wrong?zcbenz commentedon Dec 31, 2015
@Ivshti You need to add a
_closecall inArchive::~Archivefor Windows, for POSIX the fd is destroyed automatically, I forgot to do the same for Windows.Ivshti commentedon Dec 31, 2015
Couldn't find a destructor at all... I have to look again apparently
Ivshti commentedon Jan 1, 2016
@zcbenz how does this work?
https://github.com/atom/electron/blob/0d50e08ed106ae2897d6320966b47ac0357b8da1/atom/common/asar/archive.cc#L117-L132
So MSDN says
Do I just do this: ?
zcbenz commentedon Jan 4, 2016
Yeah.
zcbenz commentedon May 6, 2016
I'm closing this since we don't have plan to work on it, feel free publishing a PR if anyone is interested.