main: safeguard creation of orphaned files

This commit is contained in:
Thomas Schoebel-Theuer 2021-02-15 18:46:38 +01:00 committed by Thomas Schoebel-Theuer
parent 9491714e28
commit a615ef907b
1 changed files with 4 additions and 0 deletions

View File

@ -2765,6 +2765,10 @@ int run_bone(struct mars_peerinfo *peer, struct mars_dent *remote_dent)
if (is_deleted ?
(stat_ok && update_mtime) :
(!stat_ok || update_mtime)) {
/* safeguard any replacement of files with symlinks */
if (stat_ok && S_ISREG(local_stat.mode)) {
(void)mars_unlink(remote_path);
}
status = ordered_symlink(remote_dent->new_link,
remote_path,
&remote_dent->new_stat.mtime);