From: Joel Rosdahl Date: Mon, 5 Sep 2022 11:00:59 +0000 (+0200) Subject: fix: Don't fail if object file exists and is unwritable X-Git-Tag: v4.7~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1854477c7b5989f5ba2ab817458a443fc9233173;p=thirdparty%2Fccache.git fix: Don't fail if object file exists and is unwritable --- diff --git a/src/Util.cpp b/src/Util.cpp index 4e713d9fa..2208de0e4 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -352,6 +352,8 @@ copy_file(const std::string& src, const std::string& dest, bool via_tmp_file) throw core::Error(FMT("{}: {}", src, strerror(errno))); } + unlink(dest.c_str()); + Fd dest_fd; std::string tmp_file; if (via_tmp_file) { diff --git a/test/suites/hardlink.bash b/test/suites/hardlink.bash index cf3c5304e..31c58f0e5 100644 --- a/test/suites/hardlink.bash +++ b/test/suites/hardlink.bash @@ -31,6 +31,15 @@ SUITE_hardlink() { test_failed "Object files not hard linked" fi + $CCACHE_COMPILE -c test1.c + expect_stat preprocessed_cache_hit 2 + expect_stat cache_miss 1 + expect_stat files_in_cache 2 + + if [ test1.o -ef test1.o.saved ]; then + test_failed "Object files are hard linked" + fi + # ------------------------------------------------------------------------- TEST "Corrupted file size is detected"