Cannot Re-use content on another platform
the CLI interface offers to Reuse Content as Download etc but it does not work: when importing the saved content into another platform! I get error message "A valid content folder is missing". Same problem if I use the CLI Export content command.
You may want to leave some more information. I can't reproduce/confirm this issue.
I'd just like to add a word of advice here. Be aware that the H5P CLI tool, when using the setup command, will use the sources of the master branches of the github repositories. That's usually not the release version, but a development version. If you use the H5P CLI tool blindly to build H5P files in order to install these on some other H5P integration, you risk installing untested buggy code on that platform and potentially even spread it if people download the respective content and upload it on their system. See also https://github.com/h5p/h5p-cli/issues/55
So, if that applies to your case, please rather pack the libraries that you have been working on, and then install only those on the other platform, and then create demo content or whatever on that platform.
Thanks for the advice, @otacke ! I will be careful with contents created with the H5P CLI tool...
Here is more information as requested by @otacke Scenario to test issue with a simple H5P content
- download True/False Question number 1 "Oslo is the capital of Norway" from https://h5p.org/true-false
- saved as true-false-question-34806.h5p
- in localhost CLI tool Import it, entitle it "Oslo true-false"
- View it and export it with Reuse button -> Download as an .h5p file
- Check that you've got the file Oslo-true-false.h5p in your Downloads folder on your computer
- Go to any one of these 3 platforms (local or online): Moodle, Drupal7 or WordPress
- and Download/Import the file Oslo-true-false.h5p
- Check that you get error message: A valid content folder is missing
- Open Lumi: Open Existing H5P -> Oslo-true-false.h5p
- Check that you can import it without errors
- In Lumi: Save As "Oslo-true-false-from-Lumi"
- Go back to any one of these 3 platforms (local or online): Moodle, Drupal7 or WordPress
- and Download/Import the file Oslo-true-false-from-Lumi.h5p
- Check that it is imported with no errors!
Still cannot reproduce this. Might be an issue with running adm-zip inside the H5P CLI tool on Windows (?) only.
I cannot reproduce this either. On Windows it is recommended that you run the h5p-cli commands inside git bash.
@devland and @otacke I am still experiencing this issue. When you say "cannot reproduce" do you mean you have actually tried my scenario on a Windows platform? @devland Running the h5p-cli commands in git bash does not enter in consideration when Re-using the contents. @otacke probably has the correct explanation, so, how about making adm-zip work on Windows?
@rezeau Nope. Did not try this on Windows. Otherwise I could have looked into the cause instead of speculating. You didn't mention Windows at all before, so I merely guessed because I know you that are bold enough to use it.
@otacke Yes, I am bold/foolish enough to stick to Windows.😵💫
In the h5p-cli tools the pack library command works OK. That command calls the adm-zip script, but only the first part of it.
The export content command (used by the Re-use link in the server interface) starts with exporting all the libraries needed by the particular content that is being exported, then it continues with the module.exports function.
As far as I can see the Windows bug lies somewhere in that function. It would be great if a fix could be found.
@rezeau I don't know how much impact creating issues on github has. From what I experience, currently what does not exist on H5P Group's JIRA instance, does not have a good chance to be tackled any time soon except for some lucky cases.
@otacke Done at https://h5ptechnology.atlassian.net/browse/HFP-4159 Probably not the best of bug reports but can't do better at the moment. And of course I don't expect any fix to happen any time soon. "Blessed is he who expects nothing, for he shall never be disappointed" Alexander Pope.
@rezeau Sure, but expecting nothing sounds a lot like living half-asleep. I am not the maintainer anyway ;-)
I managed to reproduce this issue on my windows vm. It seems that the adm-zip npm module works inconsistently between OSs.
Wanted to report I am also facing this issue on windows.
If I use the little "reuse" button on the bottom of a content -> download as h5p and import it into a real h5p instance, I get "a valid content folder is missing".
If I unzip that same h5p file and then re-zip it with zip -rDX myNewFile.h5p * (zip for windows) - It suddenly works.
@Gremious Only repeating the note that I posted earlier:
_"I'd just like to add a word of advice here. Be aware that the H5P CLI tool, when using the setup command, will use the sources of the master branches of the github repositories. That's usually not the release version, but a development version. If you use the H5P CLI tool blindly to build H5P files in order to install these on some other H5P integration, you risk installing untested buggy code on that platform and potentially even spread it if people download the respective content and upload it on their system. See also https://github.com/h5p/h5p-cli/issues/55
So, if that applies to your case, please rather pack the libraries that you have been working on, and then install only those on the other platform, and then create demo content or whatever on that platform."_
I'm not sure this applies to me, as I have not used h5p setup, I only ever ran h5p core.
The libraries in the project are entirely my own + the default H5P.MathDisplay-1.0, h5p-php-library and h5p-editor-php-library, which my libraries do not call out as dependencies in their library.json's. Those are not getting packed into the .h5p file and are not present in the "Libraries" page of my actual H5P integration.
@Gremious Then in your case that scenario is fine - but one should still know about this.
Fixed by updating adm-zip to v0.5.16. https://github.com/h5p/h5p-cli/pull/127 Should be merged to master soon with a new npm version to be pushed out shortly after that.
@otacke Can you check if you are experiencing the problem from https://github.com/cthackers/adm-zip/issues/533 with v.0.5.16 of adm-zip?
@devland That was a Windows issue, right? Don't have that running, but could spin up a virtual machine later today.
@otacke No, that's for Linux on your own system. I remember that you reported the issue from https://github.com/cthackers/adm-zip/issues/533 but I could not reproduce it so I pinned adm-zip at 0.5.14 as a work-around.
@devland Installed the HFP-4159 branch on VM running Windows, exported content and uploaded it to a moodle instance and a WordPress instance without experiencing any issues. Good job.
@devland Oh, only seeing that now ...
@devland Everything seems to run nicely on Linux, too.
@devland Tried to upload https://dhantest.knask.h5p.com/content/1292514178145751396 to a fresh H5P CLI instance (latast master) and get Error: ADM-ZIP: Descriptor data is malformed.
@otacke I can also reproduce the error with your sample content.
It's generated by this line in adm-zip: https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/zipEntry.js#L62
when descriptor.size does not match _centralHeader.size.
For our example the values are 0 and 57 respectively.
This is definitely a bug from adm-zip because, if you comment out the error, the extraction proceeds normally and you can load the content in your browser. I'll update https://github.com/cthackers/adm-zip/issues/533 with instructions on how to reproduce this.
As a workaround you can simply comment out the error from https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/zipEntry.js#L62.
Issue fixed. v1.1.3 of the h5p-cli has been pushed to the npm registry.
Tested on Moodle and Wordpress (I've given up Drupal). Works as expected, thanks all who worked to fix this bug!