emmercm / igir

🕹 A video game ROM collection manager to help filter, sort, patch, archive, and report on collections on any OS.
https://igir.io/
GNU General Public License v3.0
308 stars 16 forks source link

`copy zip` on MAME rom resulting in `Type_a.getHeader is not a function` error #568

Closed kbullett closed 11 months ago

kbullett commented 11 months ago

Paste the command

npx igir@latest copy zip --dat roms/dats/MAME\ Dats\ 0.78/MAME\ 078.dat --input MAME_2003-Plus_Reference_Set_2018/roms/3countb.zip --output roms/roms-sorted --dir-dat-name

Describe the bug

Working from 0.78 MAME romset and for test purposes, running against 1 specific rom I get the following error (below is full output),

✓ Scanning for DATs ············ | 1 unique DAT found
✓ Scanning for ROMs ············ | 27 files found
ERROR: MAME: roms/roms-sorted/MAME/neogeo.zip: failed to create zip: Type_a.getHeader is not a function
ERROR: MAME: roms/roms-sorted/MAME/3countb.zip: failed to create zip: Type_a.getHeader is not a function
✓ MAME ························· | 2/4,610 games, 1/15 BIOSes, 2/4,610 retail releases written
✓ Processing DATs ·············· | 1 DAT processed

If I try do a copy and do not include a zip then I get the following error,

✓ Scanning for DATs ············ | 1 unique DAT found
✓ Scanning for ROMs ············ | 27 files found
⚙ Processing DATs ·············· | ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ | 0/1
✎ MAME ························· | ░░░░░░░░░░░░░░░░░░░░░░░░░ | 0/1file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/types/logiqx/dat.js:154
        if ((_a = this.getHeader().getClrMamePro()) === null || _a === void 0 ? void 0 : _a.getHeader()) {
                                                                                            ^

TypeError: _a.getHeader is not a function
    at DAT.isHeadered (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/types/logiqx/dat.js:154:93)
    at Options.canRemoveHeader (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/types/options.js:610:17)
    at CandidateWriter.<anonymous> (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:279:47)
    at Generator.next (<anonymous>)
    at file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:3:12)
    at CandidateWriter.writeRawFile (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:278:16)
    at CandidateWriter.<anonymous> (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:264:30)
    at Generator.next (<anonymous>)
    at fulfilled (file:///Users/kristan/.npm/_npx/0d8028b15d717946/node_modules/igir/build/src/modules/candidateWriter.js:4:58)

Node.js v18.5.0

Expected behavior

Expect rom to be identified and copied to the output dir.

Debug logs

[13:16:07.601] INFO: CandidatePreferer: MAME: done filtering candidates [13:16:07.601] INFO: CandidatePostProcessor: MAME: processing candidates [13:16:07.681] INFO: CandidatePostProcessor: MAME: done processing candidates [13:16:07.682] INFO: CandidateWriter: MAME: writing 2 candidates [13:16:07.683] TRACE: CandidateWriter: MAME: neogeo: writing 2 candidates [13:16:07.684] TRACE: CandidateWriter: MAME: roms/roms-sorted/MAME/neogeo.zip: writing 10 archive entries ... [13:16:07.701] ERROR: CandidateWriter: MAME: roms/roms-sorted/MAME/neogeo.zip: failed to create zip: Type_a.getHeader is not a function [13:16:07.701] TRACE: CandidateWriter: MAME: neogeo: no raw files to write [13:16:07.701] TRACE: CandidateWriter: MAME: roms/roms-sorted/MAME/3countb.zip: writing 20 archive entries ... [13:16:07.708] ERROR: CandidateWriter: MAME: roms/roms-sorted/MAME/3countb.zip: failed to create zip: Type_a.getHeader is not a function [13:16:07.708] TRACE: CandidateWriter: MAME: 3countb: no raw files to write [13:16:07.708] TRACE: CandidateWriter: MAME: neogeo: done writing 2 candidates [13:16:07.708] INFO: CandidateWriter: MAME: done writing 2 candidates [13:16:07.709] INFO: StatusGenerator: MAME: generating ROM statuses [13:16:07.720] INFO: StatusGenerator: MAME: done generating ROM statuses MAME ... 2/4,610 games, 1/15 BIOSes, 2/4,610 retail releases written [13:16:07.721] INFO: done processing 1 DAT

DAT(s) used

https://www.progettosnaps.net/download/?tipo=dat_mame&file=/dats/MAME/MAME_Dats_078.rar

igir version

v1.9.0

Node.js version

v18.5.0

Operating system

macOS Sonoma 14.0

Additional context

No response

kbullett commented 11 months ago

FYI roms tested are from a full non-merged romset.

emmercm commented 11 months ago

Fascinating, that's telling me that the DAT doesn't have a header, or it couldn't parse one correctly. I will try to reproduce it.

emmercm commented 11 months ago

It's because an XML library I'm using is coercing the self-closing <clrmamepro/> to be an empty string...

<datafile>
    <header>
        <name>MAME</name>
        <description>MAME 0.78</description>
        <category>EMULATION</category>
        <version>0.78</version>
        <date>-not specified-</date>
        <author>AntoPISA</author>
        <email>progettosnaps@gmail.com</email>
        <homepage>http://www.progettosnaps.net/</homepage>
        <url>-not specified-</url>
        <comment>-not specified-</comment>
        <clrmamepro/>
    </header>

I'll put in a fix for this and other potential places.

kbullett commented 11 months ago

Very nice. Thanks for turning this around so quickly. I updated my .dat to remove the clrmamepro element and can now process these MAME roms. Amazing! BTW, you have written a lovely tool here. I am a big fan.

emmercm commented 11 months ago

You're very welcome, this should be fixed in the next release. Thank you, @kbullett!

github-actions[bot] commented 9 months ago

:lock: Inactive issue lock

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.