summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-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);