Zip/rar works just with npm start, but fails when packaged


#1

I am working on a comicbook reader, where I need to run through a few zip or rar files, extract them to a folder in os.tmpdir(). While starting up the app with npm start and electron-prebuilt, the extraction works just fine. After packaging the app with electron-packager, the app no longer works as intended; simply the file extractors fail to do so.

Is it possible that os.tmpdir() is restricted based on permissions, or what could be the issue?

Github Repo


#2

Why don’t you check what errors the extractors produce instead of just guessing?


#3

I took a brief look at the repo and I’m assuming you are referring to the execution starting on line 56 in file.js?

Without actually cloning the repo and packaging the app, it is difficult to diagnosis what the problem is. I would second the idea of inspecting the extractors and maybe add some logging.

The additional logging could also provide visibility to what’s happening, even with debug = false.

I also see you using a function, handleError, that doesn’t appear to be defined.


#4

Also, instead of using os.tmpdir(), you might consider app.getPath(name)


#5

What are the advantages of app.getPath(name)? It also seems like it would be invoked from index.js and not the app itself, if I’m reading the documentation correctly.

I switched out the unrar/extract-zip for a more globalized version, since I couldn’t open up a file on my Windows machine, so hopefully this next build will work.


#6

app.getPathName is a more universal utility to get temporary files, user library files, etc…

You can also access app from any module that has nodeIntegration available via require.

Good luck with the new implementation.


#7

Thank you! I’ll be back in about 15 minutes when I end up breaking something else :stuck_out_tongue:


#8

Did you get anywhere with this? I ask, because I’m now facing the same issue. :frowning:

I’m using node-7z and unrar, so far I’m struggling to find where the problem is. I can read a zip file and fetch the content but when it comes to extracting it fails.

I thought it could be the temp file path, I’m using tmp to generate and create the temporary folder. I even switched to telling it to use dir: app.getPath('temp') so it would use the system temp location.

As you say, works fine from npm start but not when as a distributable exe file :frowning: