flac icon indicating copy to clipboard operation
flac copied to clipboard

Zero-byte files left behind when trying to flac.exe out of subset

Open H2Swine opened this issue 2 years ago • 4 comments

1.4.2 for Windows, the file is CDDA so that -b8192 is out of subset.

Scenario 1: flac -fb8192 file.flac Result: Leaves zero-byte .tmp,fl-ac+en'c . At least it tells me what file I failed at.

Scenario 2: flac -t file.flac flac -fb8192 file.wav Result: Overwrites file.flac with a zero-byte file.

Expected: at least in the last scenario, it should throw error and do nothing at all?

H2Swine avatar Jun 01 '23 18:06 H2Swine

At least part of this is fixed in #506

Could you check with a recent binary from https://hydrogenaud.io/index.php/topic,123176.msg1027870.html#msg1027870

ktmf01 avatar Jun 01 '23 19:06 ktmf01

That one leaves no trace. Although I am not sure if it is wanted behaviour ... ? Maybe it is in line with what flac -f file.wav does otherwise, which is (I think?) delete file.flac first and then do whatever comes out of it. Most likely a user who gives flac -f file.wav wants file.flac overwritten with a valid lossless file or not overwritten at all, but that isn't the behaviour in other situations either?

H2Swine avatar Jun 01 '23 20:06 H2Swine

I'm unsure whether fixing this would be an improvement.

As far as I know, currently, using -f always results in the deletion of any file that has the name of the intended output file. I could take a look at the code whether it is possible to delay the removal of that file until as late as possible. That would 'solve' a few cases like this, but then behaviour isn't as consistent anymore: it is no longer clear when the file will be removed and when it will not be. An error during initialization might be 'caught', but an error during encoding itself will not be. For a user, it is no longer clear what to expect.

Furthermore, in the specific case you mention, it is reasonable to assume the user will try again, overwriting the file anyway.

ktmf01 avatar Jun 02 '23 06:06 ktmf01

I'm also not sure, so maybe this issue can be closed as completed.

But - luckily! - the following isn't correct:

As far as I know, currently, using -f always results in the deletion of any file that has the name of the intended output file.

Not always. Not upon recompression - then source isn't deleted until target is done. (And please keep it that way.)

H2Swine avatar Jun 02 '23 08:06 H2Swine