sandreas / tone

tone is a cross platform audio tagger and metadata editor to dump and modify metadata for a wide variety of formats, including mp3, m4b, flac and more. It has no dependencies and can be downloaded as single binary for Windows, macOS, Linux and other common platforms.
https://pilabor.com
Apache License 2.0
410 stars 17 forks source link

tone tag exit gracefully after Control-C is pressed #22

Closed rloomans closed 2 years ago

rloomans commented 2 years ago

I had tone writing tags to a collection of .m4b files and I needed to interrupt it so I could get something else done.

When I pressed Control-C tone exited immediately and left the file it was writing to corrupted so that it was unrecognisable and unplayable.

Tone should either write a new file and rename into place, and/or install a signal handler to exit gracefully once it's finished writing the current file. Ideally, it should do both

sandreas commented 2 years ago

Thanks for sharing this... I'm sorry if it damaged your files.

Maybe this is the way to go:

rloomans commented 2 years ago

Definitely do the graceful termination.

The other thing (that I call "rename into place" above) is where apps write a new file, close it, and then rename it over the old file. That way you either get the old file or the new file, not a corrupted mix of the two.

(My files are sitting on a NAS with filesystem snapshots... I noticed right away and could pull out an older copy)

sandreas commented 2 years ago

Fixed in latest code, targeted for release v0.0.9

sandreas commented 2 years ago

v0.0.9 has been released, feedback would be very welcome. If this happens to you again, I have to take another look.