warc icon indicating copy to clipboard operation
warc copied to clipboard

`WarcReader::from_path` creates the file, is that intended?

Open dis-archive opened this issue 10 months ago • 5 comments

dis-archive avatar Feb 17 '25 11:02 dis-archive

Probably wasn't intended. It seems the combination of options:

        let file = fs::OpenOptions::new()
            .read(true)
            .create(true)
            .truncate(false)
            .open(&path)?;

is invalid and throws an error for me.

desmondcheongzx avatar Feb 24 '25 05:02 desmondcheongzx

This might be an unrelated issue but when I run the read_file example, I get an InvalidInput error.

Error: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }

@desmondcheongzx are you getting the same error?

extua avatar Mar 10 '25 16:03 extua

Previously this was

let file = fs::OpenOptions::new()
    .read(true)
    .write(true)
    .create(true)
    .open(&path)?;

And then this commit removed write(true) and inserted truncate(false).

I tested it and just re-adding write(true) will get it to work, but maybe this breaks some clippy lint. @ahartel what do you think?

extua avatar Mar 10 '25 16:03 extua

Why not just remove .write and .truncate since this is inside the reader?

desmondcheongzx avatar Mar 10 '25 20:03 desmondcheongzx

Why not just remove .write and .truncate since this is inside the reader?

Good point, I've created a pull request to cut the options down to just read(true) and open(&path).

extua avatar Mar 10 '25 22:03 extua