j68k / verifydump

A tool for verifying that .chd/.rvz disc images match Redump Datfiles
MIT License
51 stars 7 forks source link

verifydump chokes on filenames containing brackets [] #16

Open coreyemtp opened 2 years ago

coreyemtp commented 2 years ago

As stated, a filename such as:

XI [sai] (Japan) (Demo 2).chd

Will cause the following error in PowerShell 7, Windows 11:

W:\PlayStation (CHD)>verifydump.exe --extra-cue-source "R:_Emu_ROM Managers\DATs\Redump (Other)\Cuesheets" "R:_emu_ROM Managers\DATs\1G1R\Redump\Sony - PlayStation (2022-07-01 03-24-24) (Retool 2022-07-06 12-33-55) (6,196).dat" ".\XI [sai] (Japan) (Demo 2).chd" Datfile loaded successfully with 6196 games Traceback (most recent call last): File "exeentry.py", line 5, in File "verifydump\console.py", line 45, in verifydump_main File "verifydump\verify.py", line 258, in verify_dumps File "verifydump\verify.py", line 240, in verify_dump_if_format_is_supported File "verifydump\verify.py", line 39, in verify_chd File "verifydump\convert.py", line 30, in convert_chd_to_normalized_redump_dump_folder File "verifydump\convert.py", line 63, in normalize_redump_bincue_dump FileNotFoundError: [WinError 2] The system cannot find the file specified: 'Z:\TEMP\tmpf1eldev4\XI [sai] (Japan) (Demo 2) (Track 1).bin' -> 'Z:\TEMP\tmpf1eldev4\XI [sai] (Japan) (Demo 2).bin' [5200] Failed to execute script 'exeentry' due to unhandled exception!

Simply renaming the file, removing the brackets causes it to work correctly, though it does then complain about the filename not matching the DAT.

j68k commented 2 years ago

That's an interesting one. Thanks very much for the report!

coreyemtp commented 2 years ago

Happy to help in any way I can, verifydump has saved me countless hours of work!

Z-95 commented 2 years ago

The problem is in convert.py on line 56--the pathlib glob treats the brackets in the filename as part of the pattern to match.

I changed the pattern to "*(Track *).bin" and tested it against "Holiday Special (Japan).chd" which has only one .bin and "XI [sai] (Japan) (Demo 2).chd" and both verified successfully (this is with verbose on):

Loading Datfile "Sony - PlayStation - Datfile (10660) (2022-07-20 18-03-14).dat" from "Sony - PlayStation - Datfile (10660) (2022-07-20 18-03-14).zip" Datfile loaded successfully with 10660 games Verifying dump file "S:\Roms\ps\Holiday Special (Japan).chd" Converting "Holiday Special (Japan).chd" to .bin/.cue format Splitting "Holiday Special (Japan).cue" to use separate tracks if necessary Renaming "Holiday Special (Japan) (Track 1).bin" to "Holiday Special (Japan).bin" because there is only one .bin file in the dump Dump file "Holiday Special (Japan).bin" found in Dat and verified Dump file "Holiday Special (Japan).cue" found in Dat and verified Dump verified correct and complete: "Holiday Special (Japan)" Verifying dump file "S:\Roms\ps\XI [sai] (Japan) (Demo 2).chd" Converting "XI [sai] (Japan) (Demo 2).chd" to .bin/.cue format Splitting "XI [sai] (Japan) (Demo 2).cue" to use separate tracks if necessary Dump file "XI [sai] (Japan) (Demo 2) (Track 01).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 02).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 03).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 04).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 05).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 06).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 07).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 08).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 09).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 10).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 11).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2) (Track 12).bin" found in Dat and verified Dump file "XI [sai] (Japan) (Demo 2).cue" found in Dat and verified Dump verified correct and complete: "XI [sai] (Japan) (Demo 2)" Successfully verified 2 dumps

Unsure if that change would have any side effects since that temp dir should only have .bins from the single extracted .chd I think?

j68k commented 2 years ago

Ahh, awesome work figuring that out @Z-95! I see that the underlying filename matching module fnmatch supports escaping parts of the pattern and from a quick test it looks like it'll work if the brackets are escaped. Thanks very much!