openzim / libzim

Reference implementation of the ZIM specification
https://download.openzim.org/release/libzim/
GNU General Public License v2.0
165 stars 49 forks source link

iOS: Unable to open file (which works in Kiwix elsewhere) #901

Open kelson42 opened 3 months ago

kelson42 commented 3 months ago

From kiwix-apple created by stuartlangridge: kiwix/kiwix-apple#842

I have created a .zim file for myself, and it happily opens in kiwix-desktop on Ubuntu. However, when I download that file (with Safari) on my iPhone, and then try to open it in Kiwix for iOS from the Downloads folder, Kiwix responds "Unable to open file: blah.zim cannot be opened". Is there any way I can find out why it can't be opened, so I can work to resolve it? There does not seem to be a way; the syslog on the device does not seem to mention the file by name, so I don't think that Kiwix is NSLog()ing a failure reason, although I might be wrong about that. I did not (and cannot) compile my own Kiwix; I'm just using the one from the Apple app store for iOS.

kelson42 commented 3 months ago

Thank you @stuartlangridgemmformyour issue, you should definitly be able to open your ZIM files and have a similar user experience on all versions of Kiwix.

Let me as you two questions:

kelson42 commented 3 months ago
  • How have you created your ZIM file? With which tool?

I used the Python bindings for libzim to create my zim file, as packaged in Ubuntu 22.04. These seem to be 1.0.0+ds-2build1, based on libzim in Ubuntu which is version 7.2.0-2build1.

I was not using v3.4.0 of Kiwix for iOS, but I have just updated to that and tried again and I have the same issue.

(I should note that I have opened a different zim file from inside the Kiwix interface and that worked, so my Kiwix installation for iOS isn't completely broken or anything!)

kelson42 commented 3 months ago

@stuartlangridge OK, then its looks like a bug. Would you be able to share the ZIM file, or any ZIM file suffering of the bug?

kelson42 commented 3 months ago

@stuartlangridge It seems as well that you use a very old version of python-libzim, any chance you could use the latest version published on pypi?

kelson42 commented 3 months ago

I have just tried using libzim from pypi, and I still get the problem, it seems. You can grab a small example file which shows the problem (it loads fine in kiwix-desktop, but does not in kiwix-ios) and was created with up-to-date PyPI install from https://kryogenix.org/random/fr-small-pip.zim. (I'm quite prepared to believe that I'm creating the zim file wrong in some way! but it does open in kiwix-desktop, so it can't be completely wrong. It might be useful, if the file really is created incorrectly, if kiwix-ios gave some direction as to why the file can't be loaded, to help people who create their own zim files.)

kelson42 commented 3 months ago

@stuartlangridge I rna zimcheck against your file, and I see:

[ERROR] Metadata errors:
  Missing mandatory metadata: Language
  Missing mandatory metadata: Date
  Missing mandatory metadata: Illustration_48x48@1

At this stage, I guess there is 50% chance that the rootcause of the problem is there because these Metadata are mandatory in the ZIM spec. Would you be able to set them and try again?

kelson42 commented 3 months ago

Aha, I didn't know there was a zimcheck tool! Now that I know that I'll try again and verify with zimcheck, thank you.

kelson42 commented 3 months ago

...and that has indeed fixed it! My created zim file now opens fine in Kiwix for iOS, now that I've added language, date, and illustration.

I shall file a bug against the python libzim bindings because their example code in their README does not include these mandatory elements, but this bug can be closed, and thank you!

kelson42 commented 3 months ago

@rgaudin @benoit74 Actually I believe this is not really normal that a ZIM file can be written without error by python-libzim if the ZIM file can not be open afterward.

kelson42 commented 3 months ago

python-libzim is a wrapper. If libzim allows it, pylibzim should as well

kelson42 commented 3 months ago

@mgautierfr ?

kelson42 commented 3 months ago

I will transfer to openzim/libzim.

mgautierfr commented 3 months ago

Actually I believe this is not really normal that a ZIM file can be written without error by python-libzim if the ZIM file can not be open afterward.

Well, it seems that is a issue with iOS only. Probably because iOS expect some metadata and fail if they are not there. From user itself, it seems that open the file is ok on other readers.

python-libzim is a wrapper. If libzim allows it, pylibzim should as well

I agree.


Libzim itself can read such a file (and it is a good thing, else zimcheck would not be able to open it to check it). So on the reading side we are good.

On the creation side, I refer you to https://github.com/openzim/libzim/issues/785 (and suggest we continue the discussion there)

kelson42 commented 2 weeks ago

We should clarify what is blocking for opening a file at libzim level and at Kiwix levels. Once agreement on this, check that implementations are correct.