]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Copy dia file even if compiling failed
authorThomas Röfer <Thomas.Roefer@dfki.de>
Wed, 22 May 2013 13:02:21 +0000 (15:02 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Aug 2013 20:37:04 +0000 (22:37 +0200)
ccache.c

index 0d6df545259bf1c0e83ee7c2b31afe4929afd2cb..ada3edfadf5f0430bf4db6755e17dbe67af03308 100644 (file)
--- 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);
                        }
                }