Skip to content

Fix zip-of-zips subdirectories for single files - #477

Merged
mjmusante merged 1 commit into
iftechfoundation:mainfrom
dfabulich:fix-zip-of-zip-subdirectories
Sep 3, 2026
Merged

Fix zip-of-zips subdirectories for single files#477
mjmusante merged 1 commit into
iftechfoundation:mainfrom
dfabulich:fix-zip-of-zip-subdirectories

Conversation

@dfabulich

@dfabulich dfabulich commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

https://metacpan.org/pod/Archive::Zip#addFile(-$fileName-[,-$newName,-$compressionLevel-]-)

When we pass just one argument to addFile, the zip member name is set to the unnormalized absolute path to the $src_file.

Fixes #476

I manually tested this using #478. On that branch, I reproduced the bug:

dfab: ~/git/ifcomp/IFComp-Dev % script/build_zip_of_zips.sh
dfab: ~/git/ifcomp/IFComp-Dev % script/shell.sh
root@3a2cfdb9c809:/opt/IFComp# find ~/2026/Games -name '*.zip' -print0 | xargs -0 -n 1 unzip -l
Output before the fix

root@3a2cfdb9c809:/opt/IFComp# find ~/2026/Games -name '*.zip' -print0 | xargs -0 -n 1 unzip -l
Archive:  /root/2026/Games/Test_TADS_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   opt/IFComp/script/../entries/109/main/fake.gam
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Glulx_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   608160  2026-09-01 23:44   opt/IFComp/script/../entries/101/main/Naked glulx.gblorb
---------                     -------
   608160                     1 file
Archive:  /root/2026/Games/Test_Z-code_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   410016  2026-09-01 23:44   opt/IFComp/script/../entries/100/main/Naked zcode.zblorb
---------                     -------
   410016                     1 file
Archive:  /root/2026/Games/Test_HTML_page.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   opt/IFComp/script/../entries/106/main/my-game.html
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Z-code_website_with_buried_story_file.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 20:00   Release/
     6148  2017-07-25 20:00   Release/.DS_Store
        0  2017-07-25 20:01   __MACOSX/
        0  2017-07-25 20:01   __MACOSX/Release/
      120  2017-07-25 20:00   __MACOSX/Release/._.DS_Store
    90647  2017-07-25 19:59   Release/Cover.jpg
     1935  2017-07-25 19:59   Release/index.html
    29296  2017-07-25 19:59   Release/Small Cover.jpg
        0  2017-07-25 20:00   Release/stuff/
   410020  2017-07-25 19:59   Release/stuff/Parchment game.zblorb
     6854  2017-07-25 19:59   Release/style.css
---------                     -------
   545020                     11 files
Archive:  /root/2026/Games/Test_Quest_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   opt/IFComp/script/../entries/108/main/fake.quest
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Parchment_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 19:43   Release/
    90647  2017-07-25 19:43   Release/Cover.jpg
     1935  2017-07-25 19:43   Release/index.html
        0  2017-07-25 19:43   Release/interpreter/
    95957  2017-07-25 19:43   Release/interpreter/jquery.min.js
   423958  2017-07-25 19:43   Release/interpreter/Parchment game.zblorb.js
     1816  2017-07-25 19:43   Release/interpreter/parchment.min.css
    18649  2017-07-25 19:43   Release/interpreter/parchment.min.js
    29541  2017-07-25 19:43   Release/interpreter/zvm.min.js
   410020  2017-07-25 19:43   Release/Parchment game.zblorb
     1426  2017-07-25 19:43   Release/play.html
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     6854  2017-07-25 19:43   Release/style.css
---------                     -------
  1110099                     13 files
Archive:  /root/2026/Games/Test_Z-code_website.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 19:49   Release/
     6148  2017-07-25 19:49   Release/.DS_Store
        0  2017-07-25 19:50   __MACOSX/
        0  2017-07-25 19:50   __MACOSX/Release/
      120  2017-07-25 19:49   __MACOSX/Release/._.DS_Store
    90647  2017-07-25 19:43   Release/Cover.jpg
     1426  2017-07-25 19:43   Release/index.html
        0  2017-07-25 19:43   Release/interpreter/
    95957  2017-07-25 19:43   Release/interpreter/jquery.min.js
   423958  2017-07-25 19:43   Release/interpreter/Parchment game.zblorb.js
     1816  2017-07-25 19:43   Release/interpreter/parchment.min.css
    18649  2017-07-25 19:43   Release/interpreter/parchment.min.js
    29541  2017-07-25 19:43   Release/interpreter/zvm.min.js
   410020  2017-07-25 19:43   Release/Parchment game.zblorb
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     6854  2017-07-25 19:43   Release/style.css
---------                     -------
  1114432                     16 files
Archive:  /root/2026/Games/Test_non-Inform_website.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2020-04-29 18:13   Release/
     1426  2017-07-25 19:43   Release/index.html
     6148  2017-07-25 19:54   Release/.DS_Store
        0  2020-04-29 18:14   __MACOSX/
        0  2020-04-29 18:14   __MACOSX/Release/
      120  2017-07-25 19:54   __MACOSX/Release/._.DS_Store
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     1426  2017-07-25 19:43   Release/another-page.html
     6854  2017-07-25 19:43   Release/style.css
    90647  2017-07-25 19:43   Release/Cover.jpg
---------                     -------
   135917                     10 files

root@3a2cfdb9c809:/opt/IFComp# find ~/2026/Games -name '*.zip' -print0 | xargs -0 -n 1 unzip -l
Archive:  /root/2026/Games/Test_TADS_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   opt/IFComp/script/../entries/109/main/fake.gam
---------                     -------
     1905                     1 file

Then, I merged in this #477 branch, and the output looked like this:

fixed output

root@3a2cfdb9c809:/opt/IFComp# find ~/2026/Games -name '*.zip' -print0 | xargs -0 -n 1 unzip -l
Archive:  /root/2026/Games/Test_TADS_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   fake.gam
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Glulx_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   608160  2026-09-01 23:44   Naked glulx.gblorb
---------                     -------
   608160                     1 file
Archive:  /root/2026/Games/Test_Z-code_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   410016  2026-09-01 23:44   Naked zcode.zblorb
---------                     -------
   410016                     1 file
Archive:  /root/2026/Games/Test_HTML_page.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   my-game.html
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Z-code_website_with_buried_story_file.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 20:00   Release/
     6148  2017-07-25 20:00   Release/.DS_Store
        0  2017-07-25 20:01   __MACOSX/
        0  2017-07-25 20:01   __MACOSX/Release/
      120  2017-07-25 20:00   __MACOSX/Release/._.DS_Store
    90647  2017-07-25 19:59   Release/Cover.jpg
     1935  2017-07-25 19:59   Release/index.html
    29296  2017-07-25 19:59   Release/Small Cover.jpg
        0  2017-07-25 20:00   Release/stuff/
   410020  2017-07-25 19:59   Release/stuff/Parchment game.zblorb
     6854  2017-07-25 19:59   Release/style.css
---------                     -------
   545020                     11 files
Archive:  /root/2026/Games/Test_Quest_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   fake.quest
---------                     -------
     1905                     1 file
Archive:  /root/2026/Games/Test_Parchment_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 19:43   Release/
    90647  2017-07-25 19:43   Release/Cover.jpg
     1935  2017-07-25 19:43   Release/index.html
        0  2017-07-25 19:43   Release/interpreter/
    95957  2017-07-25 19:43   Release/interpreter/jquery.min.js
   423958  2017-07-25 19:43   Release/interpreter/Parchment game.zblorb.js
     1816  2017-07-25 19:43   Release/interpreter/parchment.min.css
    18649  2017-07-25 19:43   Release/interpreter/parchment.min.js
    29541  2017-07-25 19:43   Release/interpreter/zvm.min.js
   410020  2017-07-25 19:43   Release/Parchment game.zblorb
     1426  2017-07-25 19:43   Release/play.html
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     6854  2017-07-25 19:43   Release/style.css
---------                     -------
  1110099                     13 files
Archive:  /root/2026/Games/Test_Z-code_website.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-07-25 19:49   Release/
     6148  2017-07-25 19:49   Release/.DS_Store
        0  2017-07-25 19:50   __MACOSX/
        0  2017-07-25 19:50   __MACOSX/Release/
      120  2017-07-25 19:49   __MACOSX/Release/._.DS_Store
    90647  2017-07-25 19:43   Release/Cover.jpg
     1426  2017-07-25 19:43   Release/index.html
        0  2017-07-25 19:43   Release/interpreter/
    95957  2017-07-25 19:43   Release/interpreter/jquery.min.js
   423958  2017-07-25 19:43   Release/interpreter/Parchment game.zblorb.js
     1816  2017-07-25 19:43   Release/interpreter/parchment.min.css
    18649  2017-07-25 19:43   Release/interpreter/parchment.min.js
    29541  2017-07-25 19:43   Release/interpreter/zvm.min.js
   410020  2017-07-25 19:43   Release/Parchment game.zblorb
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     6854  2017-07-25 19:43   Release/style.css
---------                     -------
  1114432                     16 files
Archive:  /root/2026/Games/Test_non-Inform_website.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2020-04-29 18:13   Release/
     1426  2017-07-25 19:43   Release/index.html
     6148  2017-07-25 19:54   Release/.DS_Store
        0  2020-04-29 18:14   __MACOSX/
        0  2020-04-29 18:14   __MACOSX/Release/
      120  2017-07-25 19:54   __MACOSX/Release/._.DS_Store
    29296  2017-07-25 19:43   Release/Small Cover.jpg
     1426  2017-07-25 19:43   Release/another-page.html
     6854  2017-07-25 19:43   Release/style.css
    90647  2017-07-25 19:43   Release/Cover.jpg
---------                     -------
   135917                     10 files

root@3a2cfdb9c809:/opt/IFComp# find ~/2026/Games -name '*.zip' -print0 | xargs -0 -n 1 unzip -l
Archive:  /root/2026/Games/Test_TADS_game.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1905  2026-09-01 23:44   fake.gam
---------                     -------
     1905                     1 file

<https://metacpan.org/pod/Archive::Zip#addFile(-$fileName-[,-$newName,-$compressionLevel-]-)>

When we pass just one argument to `addFile`, the zip member name is set to the unnormalized absolute path to the `$src_file`.

Fixes iftechfoundation#476
@mjmusante
mjmusante merged commit 08226b8 into iftechfoundation:main Sep 3, 2026
1 check passed
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.

A bunch of sub-zips contain weird subdirectories in the start-of-comp big zip

2 participants