Skip to content

Commit

Permalink
Fix: lowercase DAT ROM checksums (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored May 31, 2024
1 parent ffa8559 commit 4e9033a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/types/dats/rom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Expose } from 'class-transformer';
import { Expose, Transform } from 'class-transformer';

import Archive from '../files/archives/archive.js';
import ArchiveEntry from '../files/archives/archiveEntry.js';
Expand Down Expand Up @@ -26,15 +26,19 @@ export default class ROM implements ROMProps {
readonly size: number;

@Expose({ name: 'crc' })
@Transform(({ value }) => value?.toLowerCase().replace(/^0x/, '').padStart(8, '0'))
readonly crc32?: string;

@Expose()
@Transform(({ value }) => value?.toLowerCase().replace(/^0x/, '').padStart(32, '0'))
readonly md5?: string;

@Expose()
@Transform(({ value }) => value?.toLowerCase().replace(/^0x/, '').padStart(40, '0'))
readonly sha1?: string;

@Expose()
@Transform(({ value }) => value?.toLowerCase().replace(/^0x/, '').padStart(64, '0'))
readonly sha256?: string;

@Expose()
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/dats/headered.dat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ clrmamepro (
game (
name "allpads"
description "allpads"
rom ( name allpads.nes size 32784 md5 dd0b01b99083da35b096da7818223802 )
rom ( name allpads.nes size 32784 md5 DD0B01B99083DA35B096DA7818223802 )
)

game (
Expand All @@ -20,7 +20,7 @@ game (
game (
name "diagnostic_test_cartridge"
description "diagnostic_test_cartridge"
rom ( name diagnostic_test_cartridge.a78 size 32896 md5 8df5c10517da1c001072fd5526e4a683 )
rom ( name diagnostic_test_cartridge.a78 size 32896 md5 8DF5C10517DA1C001072FD5526E4A683 )
)

game (
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/dats/headerless.dat
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ game (
game (
name "fds_joypad_test"
description "fds_joypad_test"
rom ( name fds_joypad_test.fds size 65484 sha1 7b6bd1a69bbc5d8121c72dd1eedfb6752fe11787 )
rom ( name fds_joypad_test.fds size 65484 sha1 7B6BD1A69BBC5D8121C72DD1EEDFB6752FE11787 )
)

game (
Expand All @@ -38,5 +38,5 @@ game (
game (
name "speed_test_v51"
description "speed_test_v51"
rom ( name speed_test_v51.sfc size 65536 sha1 2f2f061ee81bafb4c48b83993a56969012162d68 )
rom ( name speed_test_v51.sfc size 65536 sha1 2F2F061EE81BAFB4C48B83993A56969012162D68 )
)
6 changes: 3 additions & 3 deletions test/fixtures/dats/one.dat
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<machine name="Foobar">
<description>Foobar</description>
<release name="Foobar" region="USA"/>
<rom name="Foobar.lnx" size="7" crc="b22c9747" md5="14758f1afd44c09b7992073ccf00b43d" sha1="988881adc9fc3655077dc2d4d757d480b5ea0e11" status="verified"/>
<rom name="Foobar.lnx" size="7" crc="B22C9747" md5="14758F1AFD44C09B7992073CCF00B43D" sha1="988881ADC9FC3655077DC2D4D757D480B5EA0E11" status="verified"/>
</machine>
<machine name="Fizzbuzz" cloneof="Foobar">
<description>Fizzbuzz</description>
Expand All @@ -33,8 +33,8 @@
</machine>
<machine name="One Three">
<description>One Three</description>
<rom name="One.rom" size="4" crc="f817a89f" md5="5bbf5a52328e7439ae6e719dfe712200" sha1="c7059bb19433cc3cabaa6236c83d56668a843dd2" status="verified"/>
<rom name="Three.rom" size="6" crc="ff46c5d8" md5="febe6995bad457991331348f7b9c85fa" sha1="1e7720a3460b8a84ac4ba27880d64526a3872f1c" status="verified"/>
<rom name="One.rom" size="4" crc="F817A89F" md5="5BBF5A52328E7439AE6E719DFE712200" sha1="C7059BB19433CC3CABAA6236C83D56668A843DD2" status="verified"/>
<rom name="Three.rom" size="6" crc="FF46C5D8" md5="FEBE6995BAD457991331348F7B9C85FA" sha1="1E7720A3460B8A84AC4BA27880D64526A3872F1C" status="verified"/>
</machine>
<machine name="Three Four Five">
<description>Three Four Five</description>
Expand Down

0 comments on commit 4e9033a

Please sign in to comment.