From: Thomas Röfer Date: Wed, 22 May 2013 13:02:21 +0000 (+0200) Subject: Copy dia file even if compiling failed X-Git-Tag: v3.2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb7a950fc171f6b1022b3fb524cbeb9b6ab431a7;p=thirdparty%2Fccache.git Copy dia file even if compiling failed --- diff --git a/ccache.c b/ccache.c index 0d6df5452..ada3edfad 100644 --- a/ccache.c +++ b/ccache.c @@ -743,6 +743,30 @@ to_cache(struct args *args) copy_fd(fd, 2); close(fd); tmp_unlink(tmp_stderr); + + if (output_dia) { + int ret; + x_unlink(output_dia); + /* only make a hardlink if the cache file is uncompressed */ + ret = move_file(tmp_dia, output_dia, 0); + + if (ret == -1) { + if (errno == ENOENT) { + /* Someone removed the file just before we began copying? */ + cc_log("Diagnostic file %s just disappeared", output_dia); + stats_update(STATS_MISSING); + } else { + cc_log("Failed to move %s to %s: %s", + tmp_dia, output_dia, strerror(errno)); + stats_update(STATS_ERROR); + failed(); + } + x_unlink(tmp_dia); + } else { + cc_log("Created %s from %s", output_dia, tmp_dia); + } + } + exit(status); } }