Skip to content

Import a zipped pack folder from the library upload - #67

Open
lgnap wants to merge 1 commit into
antoinevalentinHA:masterfrom
lgnap:feat/import-zipped-fs-pack
Open

lgnap wants to merge 1 commit into
antoinevalentinHA:masterfrom
lgnap:feat/import-zipped-fs-pack

Conversation

@lgnap

@lgnap lgnap commented Sep 18, 2026

Copy link
Copy Markdown

What

A zip that holds a pack in the device's own layout — ni, ri, si and the rf//sf/ asset folders, as copied straight off an SD card — was handed to the archive reader on upload, which found no story.json, and the pack was silently dropped from the listing. The library reads that layout already (FsStoryPackReader, including v2-ciphered packs), but only as a folder.

The upload now unpacks such a zip into a folder of the library and does not keep the zip.

How

  • FsPackZipImporter (new): recognises the layout by content — story.json → not ours; ni+ri+si at the root or under a single top-level folder → pack folder; anything else → not ours. Unpacks under a target, refusing any entry that would land outside it.
  • LibraryService.addPackFile: when the upload is such a zip, unpacks it in the work folder first, then replaces/moves it into the library as <folder>/. The folder name is the zip's top-level folder when there is one (the reader takes the pack's UUID from the folder name), the upload's own name minus .zip otherwise. Both go through the existing libraryEntry confinement.
  • Any other zip — an archive, or something unrecognised — is stored exactly as before: saving a pack from the editor goes through the same upload, and existing tests rely on it.

Tests

LibraryFsPackImportTest, 6 specifications: unpacked under the folder's name / under the upload's name, archive stored unchanged, unknown zip stored unchanged, zip-slip entry refused with nothing written and the file outside untouched, existing folder replaced rather than merged into.

Full Java suite: 315 tests, 0 failures. Verified by hand with a real v2 pack zipped off a device: listed as format: fs under its UUID, zip consumed.

Out of scope: a zipped v3 pack carrying a bt file is unpacked as-is but only plays on the device it was ciphered for.

Closes lgnap#22

🤖 Generated with Claude Code

A zip that holds a pack in the device's own layout — ni, ri, si and the
asset folders, as copied off an SD card — was handed to the archive
reader on upload, which found no story.json, and the pack was silently
dropped from the listing. The library reads that layout already, but
only as a folder.

The upload now unpacks such a zip into a folder of the library and does
not keep the zip. The folder takes the name of the zip's single
top-level folder when there is one, since FsStoryPackReader takes the
pack's UUID from the folder name, and the upload's own name otherwise.
Unpacking happens in the work folder first: an entry that would land
outside the pack folder is refused, and nothing reaches the library.

A zip with a story.json, or one the library does not recognise, is
stored as it was — saving a pack from the editor goes through the same
upload.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import a zipped FS pack from the library upload

1 participant