mrchrisster / MiSTer_SAM

154 stars 23 forks source link

Keep the file name of unzipped ROMs. #93

Closed InquisitiveCoder closed 2 years ago

InquisitiveCoder commented 3 years ago

This addresses an issue similar to #81. Since save files, save states, screenshots, etc rely on the ROM name, renaming the extracted ROM breaks this functionality. With this change, unzipped ROMs are extracted to /tmp/MiSTer_SAM/ with their original file names. Since the files won't get overwritten any more, it also cleans up the /tmp/MiSTer_SAM directory immediately prior to unzipping another ROM.

mrchrisster commented 3 years ago

I'm not sure using unzip will work with bigger than 4gb archives. We've run into issues with this, that's why we use partun. Have you tested this on everdrive packs by chance?

InquisitiveCoder commented 3 years ago

I haven't tested any huge zips, but I'm not using unzip to perform extraction; it's being used to list out the zip file contents (-Z1 makes it output 1 file name per line.) The list then gets narrowed down using the whitelist and exclude list if they exist and whatever's left gets passed to shuf. Whichever file gets selected then gets extracted with partun.

I can make some room in my SD card and test the new code with a 4+ GB zip, but even if that turns out to be broken it shouldn't affect this PR, since the only thing I'm doing in this one is changing the name of the extracted file.

mrchrisster commented 3 years ago

Please give it a try when you can. Unzip used to have issues with even reading the contents of large zips. Not sure if it has changed with newer linux updates to the MiSTer.

InquisitiveCoder commented 3 years ago

Does it matter whether the zip is on the SD or external storage? I'm not sure my SD card will be large enough so it'd be handy if the problem can be reproduced with a USB drive.

mrchrisster commented 3 years ago

I don't think it matters, no

InquisitiveCoder commented 2 years ago

Hey, I haven't forgotten about this. I finally got some time to find a USB drive and put a 4 to 5 GB zip file on it yesterday, and you're right, unzip can't handle it. I'm not sure it's a problem specific to unzip; Windows reports the zip as corrupted as well when trying to add more files, even though I created the zip with Windows's file manager. I did a bit of searching and it might just be a limitation of many zip implementations because of how old the format is.

I think the only core that would be affected by this is in practice is GBA (1,2,3) since the CD-based cores don't support zips and the NeoGeo rollup pack I found is only 2.7 GB. For that particular use case you'd probably want to break up your collection into multiple zips anyways, considering 1000+ games would translate to over 60 pages of games on the MiSTer UI.

Still, I'm not happy that my previous pull request introduced a defect, so I'm looking into adding a "list files" option to partun. I'm not a Rust programmer but after skimming the code it doesn't seem difficult; the program already iterates through the zipped file names. It's strange it doesn't already have that option.