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
363 stars 18 forks source link

errors when copying read-only files #1080

Closed alienth closed 5 months ago

alienth commented 5 months ago

Paste the command

igir copy --dat /foo --input /bar --output /baz

Describe the bug

If igir copies a read-only file (with a mode such as 0444), it will copy those permissions as well. When it tries to do a subsequent operation on that copied file, it spams an EACCES error:

 EACCES: permission denied, open '/baz/rom.zip.1oecmkc'

When igir exits after encountering this, it leaves the temporary file in the output dir that it wrote for the copy.

I'm guessing it's trying to open the files in write-mode when it does the rename from the temp file?

Note that this error occurs regarding the file in the output directory. The directory itself has standard perms that allows it being written to.

Changing the source file to allow writes (0666) avoids the issue.

Expected behavior

A copy operation should work on files with mode 0444.

If igir needs to perform a write on a copied file, perhaps it should make the temporary file writable?

Debug logs

[01:06:44.520] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: writing 1 candidate
[01:06:44.520] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (Europe) (parent): writing 1 
candidate
[01:06:44.521] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (USA): no zip archives to write
[01:06:44.521] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (USA): writing 303.5KB of 1 file
[01:06:44.523] INFO:  CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (USA): copying file 
'/tmp/2/Zoop.zip' (303.5KB) -> '/tmp/3/Zoop (USA).zip'
[01:06:44.525] ERROR: CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (USA): /tmp/3/Zoop (USA).zip: 
failed to copy from /tmp/2/Zoop.zip: EACCES: permission denied, open '/tmp/3/Zoop (USA).zip.ob8c35'
[01:06:44.525] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: Zoop (Europe) (parent): done writing 1 
candidate
[01:06:44.525] TRACE: CandidateWriter: Nintendo - Super Nintendo Entertainment System: done writing 1 candidate
[01:06:44.525] TRACE: StatusGenerator: Nintendo - Super Nintendo Entertainment System: generating ROM statuses
[01:06:44.554] TRACE: StatusGenerator: Nintendo - Super Nintendo Entertainment System: done generating ROM statuses
✓ Nintendo - Super Nintendo En | 1/4,118 games, 0/1 BIOSes, 1/3,298 retail releases written
[01:06:44.560] TRACE: done processing 1 DAT

DAT(s) used

No-Intro

igir version

2.6.2

Node.js version

21.6.1

Operating system

Debian

Additional context

No response

emmercm commented 5 months ago

Confirmed bug, I could reproduce on my end. I'll have a fix up.

github-actions[bot] commented 4 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.

Comment generated by the GitHub Lock Issues workflow.