emmercm / igir

🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
https://igir.io/
GNU General Public License v3.0
394 stars 18 forks source link

ENOENT crash when doing `move clean test` run #1374

Open alienth opened 1 month ago

alienth commented 1 month ago

Paste the command

npm exec igir@latest move test clean -vvv --input-checksum-quick --dir-dat-name --dat ./dats --input 1g1r --output 1g1r

Describe the bug

When running move clean test runs, igir randomly crashes with ENOENT on files which it has moved to a new directory name.

In the case shown in the attached debug logs, the ROM was moved from the Atari - 5200 directory to the Atari - 8-bit Family directory by igir due to a name change in the DAT. In the same execution run, it subsequently attempted to stat the file in its old location, and crashed.

This seems similar to the fixed bug #367.

Expected behavior

igir should not attempt to access files in their old location after moving them.

Debug logs

[22:05:30.222] TRACE: CandidateArchiveFileHasher: Atari - 8-bit Family: Miner 2049er (USA): calculating checksums for: 1g1r/Atari - 5200/Miner 2049er Starring Bounty Bob (USA).zip     
[22:05:30.431] INFO:  CandidateWriter: Atari - 8-bit Family: Miner 2049er (USA): moving file '1g1r/Atari - 5200/Miner 2049er Starring Bounty Bob (USA).zip' (12.3KB) → '1g1r/Atari - 8-bit Family/Miner 2049er (USA).zip'     
[22:05:30.863] TRACE: CandidateGenerator: Atari - Atari 5200: Miner 2049er Starring Bounty Bob (USA): found 1 candidate     
[22:05:30.863] TRACE: CandidateGenerator: Atari - Atari 5200: Miner 2049er Starring Bounty Bob (USA) (parent): found 1 candidate     

Subsequent crash (occurred about 4 seconds later):

Error: ENOENT: no such file or directory, stat '1g1r/Atari - 5200/Miner 2049er Starring Bounty Bob (USA).zip'
    at async Object.stat (node:internal/fs/promises:1032:18) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '1g1r/Atari - 5200/Miner 2049er Starring Bounty Bob (USA).zip'
}

DAT(s) used

No-Intro

igir version

3.0.1

Node.js version

v20.18.0

Operating system

Debian

Additional context

No response

alienth commented 1 month ago

There is something more nuanced to this - that particular ROM that I usually see crashes on happens to be present in two separate DATs in the main No-Intro pack, both with the same checksum. I get a reliable crash when I have igir load both of those DATs, but no crash when I only load 1 of the DATs.

Furthermore, when I attempt to narrow down to only that game, and scan no other games, the crash stops reproing. That could either be due to some actual difference in the logic, or maybe just a race condition not being hit due to less processing.

The two DATs in question are Atari - 8-bit Family (Parent-Clone) (20241010-110350).dat and Atari - Atari 5200 (Parent-Clone) (20240806-183018).dat.

I'll try to dig more later to narrow down what conditions result in this outcome.