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

Disable 7-zip compression for specific static assets? #2628

Closed
NuSkooler opened this issue Feb 22, 2018 · 15 comments · Fixed by EHDFE/ehdev-shell#205 or Thorium-Sim/thorium-kiosk#40 · May be fixed by qcif/data-curator#563
Closed

Disable 7-zip compression for specific static assets? #2628

NuSkooler opened this issue Feb 22, 2018 · 15 comments · Fixed by EHDFE/ehdev-shell#205 or Thorium-Sim/thorium-kiosk#40 · May be fixed by qcif/data-curator#563

Comments

@NuSkooler
Copy link

I have a Electron built application that includes a ~900 MB static asset that already in a compressed format. When building in Linux this is a non-issue, but Windows builds using NSIS want to compress this file which adds a ton of build time (compression) and startup (decompression) time.

Is it possible to disable compression for specific static asset files?

@develar
Copy link
Member

develar commented Feb 22, 2018

We use solid compression with dictionary size 1 MB (because of differential update).

compressed format

video?

@NuSkooler
Copy link
Author

@develar In this particular case, it's a VMWare .vmdk file.

@NuSkooler
Copy link
Author

@develar Was your previous comment stating this cannot currently be done? If not, is this issue enough for a feature request?

@develar
Copy link
Member

develar commented Mar 9, 2018

Actually, you can do it right now — exclude file and then use custom nsis script to bundle using nsis File command. But it requires deep knowledge and no step by step guide...

And actually there is also another internal issue — embedded archive is not extracted directly from exe, instead, it is copied first to temp file.

Ok... so, you definitely want this feature and it will be useful for your app, right? Are you commercial company?

@NuSkooler
Copy link
Author

Yes, and yes :)

@develar
Copy link
Member

develar commented Mar 9, 2018

Ok, maybe it will be implemented tomorrow CET.

@develar
Copy link
Member

develar commented Mar 9, 2018

Dev info: embedding data using our own loader (PE wrapper) implemented in golang is a long-term plan, but for now it is ok just to generate custom file script. Nsis is awesome... but implementing zstd/7za support in C is a very complex task, that is why own golang solution is a better.

@develar
Copy link
Member

develar commented Mar 9, 2018

@NuSkooler @GeometricProgress

  1. do you use extraResources to copy such files or asar.unpack or files?
  2. do you use asar (default — enabled, did you disable it or not)?
  3. please specify relative path to such file (from project root)
  4. please specify example code how do you access such resources.

@NuSkooler
Copy link
Author

@develar In order:

  1. Currently no. I'm placing a .vmdk file in $root/static. I would like to be able to extract the file (to a user chosen path) in the future however.
  2. Default asar
  3. (above)
  4. const stream = createReadStream(paths.join(__static, 'myfile.vmdk'))

@develar
Copy link
Member

develar commented Mar 10, 2018

@NuSkooler Thanks for answer. So, I think, this feature will break you current usage and you will be forced to use process.resourcesPath in a production mode (paths.join(process.resourcesPath, "static", 'myfile.vmdk'))

What electron-builder will do: copy file AS-IS to resources/${RELATIVE_PATH_TO_FIILE} where RELATIVE_PATH_TO_FIILE it is relative path to file from current file set root (if you use default file set — it means that default file set root equals to project root).

I am not going to put this file to asar.unpacked, but need to investigate — should we to not. Maybe it will allow users to use the same code to access to such file (if asar enabled).

@develar
Copy link
Member

develar commented Mar 10, 2018

@GeometricProgress Ouch, actually it is NSIS problem to handle large files, not 7z.

@develar
Copy link
Member

develar commented Mar 10, 2018

@GeometricProgress Yeach... Windows PE is limited to 4GB. So, the only solution for you — donate us or wait when solution "golang wrapper and storing app package in the hidden area of exe file" will be implemented.

@develar
Copy link
Member

develar commented Mar 10, 2018

I don't want to introduce magic. If you have already compressed files (vm, vides), you should use extraResources. Otherwise such files will be included into asar archive (app.asar).

Option preCompressedFileExtensions is added. Defaults to [".avi", ".mov", ".m4v", ".mp4", ".m4p", ".qt", ".mkv", ".webm", ".vmdk"]. These files will be copied as is to installer (internally, using NSIS File command — not part of app package 7z archive).

So, as soon as you have specified such files in the extraResources:

"extraResources": ["**/*.mov"]

matching files will be copied to app resources and IF file extension matches one of the preCompressedFileExtensions , it will copied AS IS without compression.

So, @NuSkooler you need:

  1. add "extraResources": ["**/*. vmdk"] to your electron-builder config.
  2. check that you use correct path to resource in production mode. Hint: use process.resourcesPath (be aware — this property is not correct in dev mode).

@develar
Copy link
Member

develar commented Mar 10, 2018

20.5.0 will be published today.

@NuSkooler
Copy link
Author

Thank you so much again for the quick turn-around on this. Very helpful!

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