ollm / OpenComic

Comic and Manga reader, written with Node.js and using Electron
GNU General Public License v3.0
940 stars 80 forks source link

[Bug]: Zip (and CBZ) files fail to unzip on macOS #269

Closed brettchalupa closed 1 month ago

brettchalupa commented 1 month ago

Preflight Checklist

OpenComic Version

1.2.0

Operating System

macOS Sonoma 14.6.1

Steps to reproduce

  1. Go to Library
  2. Click the +
  3. Select Add file
  4. Select a CBZ file from the desktop to import it

Expected Behavior

File is imported and can be read

Actual Behavior

Error when unzipping and comic cannot be read

Error message

Error when unzipping spawn /Applications/OpenComic.app/Contents/Resources/app.asar.unpacked/node_modules/7zip-bin/mac/arm64/7za EACCESS

Screenshot 2024-09-16 at 9 13 33 PM

When viewing the comic in the library it shows this:

Screenshot 2024-09-16 at 9 13 37 PM

Additional Information

I downloaded the version from here: https://github.com/ollm/OpenComic/releases/tag/v1.2.0

Happens regardless of the file being named .zip or .cbz

Different error message than https://github.com/ollm/OpenComic/issues/267

.rar files work

Sample file

I put the first Pepper and Carrot episode in a zip file here for testing:

Pepper and Carrot 1.zip

griffey commented 1 month ago

Seeing exactly the same behavior on the Mac App Store version.

brettchalupa commented 1 month ago

I confirmed zips work fine on 1.2.0 on Windows 11.

ollm commented 1 month ago

It seems to be a bug in 7zip-bin https://github.com/develar/7zip-bin/issues/24, the binaries for macOS don't have the correct permissions.

I'll try if it's possible to change them with a npm prebuild or postinstall script.

ollm commented 1 month ago

I have push this fix 91c8d1d798e2b11b3f9d1cfdfe5698774dd00f05, it seems that if 7zip-bin are installed from github the binary file seems to have the correct permissions, although I have not been able to test it as it only happens on the arm64 package and I can only test the x64 package.

OpenComic-1.2.0.master.91c8d1d-arm64.dmg OpenComic-1.2.0.master.91c8d1d-arm64.pkg OpenComic-1.2.0.master.91c8d1d-arm64-mac.7z

brettchalupa commented 1 month ago

@ollm I tested the arm build you shared and am no longer seeing the reported error, but the files within the zip don't ever load and render. I just see the spinner rotating:

Screenshot 2024-10-01 at 10 42 59 PM

Happy to do more testing to help out.

brettchalupa commented 1 month ago

Quick follow up, I checked the console logs and see this:

image
Uncaught (in promise) 
Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=darwin --cpu=arm64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/Applications/OpenCo…/lib/sharp.js:113:9)
    at Object.<anonymous> (/Applications/OpenCo…/lib/sharp.js:116:3)
    at Module._compile (node:internal/modules/cjs/loader:1373:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1432:10)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:17025)
    at s._load (node:electron/js2c/renderer_init:2:31018)
    at Module.require (node:internal/modules/cjs/loader:1240:19)
    at require (node:internal/modules/helpers:179:18)
ollm commented 1 month ago

It seems that now the sharp binary for arm64 was missing, since I'm building from x64 macOS, I have fixed this with npm install --os=darwin --cpu=arm64 sharp and added some tests before building that check that all binaries are present and have the correct permissions fecd8295c68a803bedef9a98f88b29c95da97133

By the way, the sample file has corrupted images inside the __MACOSX folder and they are the ones that open by default since they are the first images. It seems that these are files generated by macOS AppleSingle/AppleDouble

New builds.

OpenComic-1.2.0.master.b812712-arm64.dmg OpenComic-1.2.0.master.b812712-arm64.pkg OpenComic-1.2.0.master.b812712-arm64-mac.7z

brettchalupa commented 1 month ago

@ollm I confirmed that provided build is working as expected now with reading zip files, thank you! 👍

ollm commented 1 month ago

Thanks for testing!

These changes are also available in the latest release v1.3.1

I close the issue as fixed.