GothenburgBitFactory / timewarrior

Timewarrior - Commandline Time Tracking and Reporting
https://timewarrior.net
MIT License
1.26k stars 95 forks source link

AtomicFile: Operate on the target of symlinks #547

Closed sruffell closed 1 year ago

sruffell commented 1 year ago

Currently, if an AtomicFile is opened on a symlink, the AtomicFile would end up overwriting the link. This change makes AtomicFiles operate on the targets of the links and not the links themselves.

NOTE: Due to the way Path is implemented in libshared, this change will not preserve links if the link does not have a valid target.

The Path::exists() will always follow links, and therefore is_link() will erroneously return false: https://github.com/GothenburgBitFactory/libshared/blob/master/src/FS.cpp#L204

lauft commented 1 year ago

Thanks for the PR! ❤️