alucryd / oxyromon

Rusty ROM OrgaNizer
Other
126 stars 14 forks source link

[Issue] Conversion failed because of Rom Name? #96

Open Zombanana opened 1 year ago

Zombanana commented 1 year ago

I think I found an issue with roms, which begin with a "-" in name.

This error ocur on this rom: http://redump.org/disc/107483/

I don't know if it's oxyromon or even on of the converters problem, but it seems it tries to interpret the name as a switch? "-8"

Screenshot 2023-09-04 172423

I am on WIndows 11, 64bit. Trying to convert this "Redump - Sony PlayStation Portable" rom from .iso to .cso.

I will try to fix the error myself by manually editing the rom name inside the dat file and manually import it into oxyromon. I will later report / confirm if the conversion work, after renaming the filename.

alucryd commented 1 year ago

Hmm, it appears to be the case indeed. I've got an external library doing the parsing, will try to see if they have a workaround, if not I'll submit a bug report over there.

Zombanana commented 1 year ago

Hi alucryd,

thanks for your work again. I have also done indeed the test. I just have renamed the file and the name of the rom inside the dat.

Renaming it from "-8 (Japan).iso" to "8 (Japan).iso". That work fine. So the - inside the begining of the name seems to produce an error.

bhartshorn commented 1 year ago

Many command line applications use '--' to indicate that all following inputs are not flags, the parsing library might support that. Was it tested?

alucryd commented 1 year ago

I actually looked at this the wrong way, this is does not concern the parsing library I use at all. This is an issue with the tool used to extract the ISO. @Zombanana What format was the file originally? Was that an ISO inside an archive?

Zombanana commented 10 months ago

I am not sure about it, as it is a while since I converted my set.

I have managed my Sets with RomVault before. I assume it was plain iso or torrentzipped, but I don't know for sure anymore.

monyarm commented 4 months ago

I have the same issue with:

❯ oxyromon convert-roms -f CHD -d -s "Sony - PlayStation"
Processing "Sony - PlayStation"
Creating "Incredible Hulk, The - The Pantheon Saga (USA).chd"
Error: SimpleError { err: "Error parsing input file (/mnt/Games/Sony - PlayStation/Incredible Hulk, The - The Pantheon Saga (USA).cue: No such file or directory)\n\nFatal error occurred: 1\n" }

Though the weird thing is I already have it converted to chd, so I'm not sure why it would be trying to convert it again. (I was running it to have it convert my newly ripped and imported games.)

alucryd commented 4 months ago

@monyarm It looks like another issue, could you open a dedicated one, and specify if it's on the stable release or the develop branch? I should be able to reproduce easily.

lemonadecbc commented 1 month ago

This same issue comes with MAME set. There's both "-" and "@" characters that are problematic with sevenzip.rs as the line 353 contains these characters unescaped, thus those are interpreted as parameter instead of filename.

I did quick & dirty local fix by replacing these characters with wildcard "?":

.arg(format!("{}", relative_path.as_os_str().to_str().unwrap()).replace("-", "?").replace("@", "?"))

Someone with better understanding how we could properly escape these characters should implement better fix.

alucryd commented 1 month ago

Had completely forgot about that, single quoting the paths will probably do the trick. I'll try that.

alucryd commented 1 month ago

It's going to be trickier than that, 7z itself is extremely bad at dealing with names starting with a hyphen, I am unsure how I can escape it. Looking into it. I considered using a pure rust alternative, but the only half decent one (sevenz-rust) just vanished from github :/ Screenshot From 2024-10-11 11-46-55

alucryd commented 1 month ago

This same issue comes with MAME set. There's both "-" and "@" characters that are problematic with sevenzip.rs as the line 353 contains these characters unescaped, thus those are interpreted as parameter instead of filename.

I did quick & dirty local fix by replacing these characters with wildcard "?":

.arg(format!("{}", relative_path.as_os_str().to_str().unwrap()).replace("-", "?").replace("@", "?"))

Someone with better understanding how we could properly escape these characters should implement better fix.

Ah! didn't realize ? worked as glob for 7z (as well as *), thank you! Just did that in https://github.com/alucryd/oxyromon/commit/920b6191f46f789b4335a0ee3407e29a6bfc8dbc I found no mention of an escape character in the 7z documentation, but indeed anything starting with - is interpreted as a switch, and @ as the path to a list of filenames.

lemonadecbc commented 1 month ago

It seems that this introduced regression in ArchiveFile implementation. If zip-file contains "-", it rn-command does not allow use of wildcard "?" and gives error. I'm not 100% sure if we even need to escape "-" here, because if I change this part of code:

    let output = Command::new(get_executable_path(SEVENZIP_EXECUTABLES)?)
        .arg("rn")
        .arg(&self.path)
        .arg(&self.file_path.replace("-", "?").replace("@", "?"))

back to:

    let output = Command::new(get_executable_path(SEVENZIP_EXECUTABLES)?)
        .arg("rn")
        .arg(&self.path)
        .arg(&self.file_path)

I'm again able to import-roms with "-" in name.

It really seems that this 7z implementation is rather painful as some commands allow wildcards and some not... If we need to escape the "-" and "@" here, it would need to be figured out how to properly escape these characters...

alucryd commented 1 month ago

Just gave it a quick test outside of oxyromon, both the rn command and a command are broken with files beginning with - or @ (with or without using glob) :/ I'll need to look for alternatives. As I pointed out above, sevenz-rust looked promising, unfortunately the repository was recently either removed or moved elsewhere and I can't find much information about it.