]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Make failure to write a stats file a soft error (#516)
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Jan 2020 10:19:52 +0000 (11:19 +0100)
committerGitHub <noreply@github.com>
Sat, 25 Jan 2020 10:19:52 +0000 (11:19 +0100)
If a stats file update for some reason fails, the exception will bubble
up to ccache_main which just prints the error and exits with an error.
Let’s consider such failures non-fatal and just log them.

src/stats.cpp

index 4a3da04d9c15afc2c990cc5f34aad2a368d18f2d..02ce7aeb31c2d0c2435ffda067f787ed44b7d828 100644 (file)
@@ -230,7 +230,13 @@ stats_write(const char* path, struct counters* counters)
   for (size_t i = 0; i < counters->size; ++i) {
     file.write(fmt::format("{}\n", counters->data[i]));
   }
-  file.commit();
+  try {
+    file.commit();
+  } catch (const Error& e) {
+    // Make failure to write a stats file a soft error since it's not important
+    // enough to fail whole the process.
+    cc_log("Error: %s", e.what());
+  }
 }
 
 static void