summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-17 21:33:08 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-17 21:33:08 +0000
commit5937ca7418d819a6070f1017ea6a563d9914df20 (patch)
tree6e6e48055e503f8c4ab05c73b6e6d59519645783
parent9f0083dea13ca1168a3d7272d83693fd03603dd4 (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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index 1f5c412..964e36f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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);