xiph / flac

Free Lossless Audio Codec
https://xiph.org/flac/
GNU Free Documentation License v1.3
1.63k stars 277 forks source link

Metaflac: Filename symlinks are overwritten if --import-picture-from is used #673

Closed lazypingu closed 1 month ago

lazypingu commented 7 months ago

I faced an issue with metaflac and symlinks. Metaflac seems to override the symlink to a filename instead of modifing the file behind the link, when using the option --import-picture-from=picture.

Other options like --set-tag or --import-cuesheet-from seems to work as expected and the link is still valid afterwards.

Version: metaflac 1.4.3 metaflac git-66152791 20240301

What would I expect: Metaflac modifies the file behind the symlink instead of the link itself when using --import-picture-from.

How to reproduce:

I also tested different shells (bash, ksh, dash), which seems to have the same result.

Not sure if this is an issue on metaflac itself. Might be also a rare case.

ktmf01 commented 7 months ago

FLAC metadata is at the start of the file. When metadata is added and padding is available for use, the metadata is rewritten in place. When not enough padding is available, the file is rewritten completely as a temporary file, then the old file is deleted and the temporary file renamed.

Of course, this doesn't work with symlinks. I am not sure yet whether there is a way to fix this.

lazypingu commented 7 months ago

Thanks for the explanation! Since this use case might be rare anyways, it could also be fine to just recommend to avoid using symlinks with flac/metaflac in general, if this is not easily changeable.

lazypingu commented 7 months ago

I've removed

Also no issues with flac --picture.

from my initial description, since flac seems to create a new file.flac instead of updating the file behind the link. So I assue this is a similar behavior as with metaflac.