diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-04-17 21:33:08 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-04-17 21:33:08 +0000 |
commit | 5937ca7418d819a6070f1017ea6a563d9914df20 (patch) | |
tree | 6e6e48055e503f8c4ab05c73b6e6d59519645783 | |
parent | 9f0083dea13ca1168a3d7272d83693fd03603dd4 (diff) |
when linking files, remove the dest file first only if the source file exists
git-svn-id: file:///home/lennart/svn/public/syrep/trunk@99 07ea20a6-d2c5-0310-9e02-9ef735347d72
-rw-r--r-- | src/util.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -489,11 +489,16 @@ finish: int copy_or_link_file(const char *src, const char *dst, int c) { - if (c) - unlink(dst); if (link(src, dst) < 0) { + if (errno == EEXIST && c) { + unlink(dst); + + if (link(src, dst) == 0) + return 0; + } + if (errno == EXDEV || errno == EPERM) return copy_file(src, dst, c); |