From 5937ca7418d819a6070f1017ea6a563d9914df20 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 17 Apr 2006 21:33:08 +0000 Subject: 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 --- src/util.c | 9 +++++++-- 1 file 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); -- cgit