]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't try to reset a non-existing stats file
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 13 Nov 2014 19:19:00 +0000 (20:19 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 13 Nov 2014 19:19:00 +0000 (20:19 +0100)
This avoids "No such file or directory" messages in the ccache log when the
cache directory doesn't exist.

lockfile.c
stats.c

index 84144a3ea48f3dd21aecf8b9ec933c7991dc5438..bce86df46ea21b7af3dc448ad139e20838363b20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2011 Joel Rosdahl
+ * Copyright (C) 2010-2014 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
diff --git a/stats.c b/stats.c
index 76cea8355a9aa3192bd1a7c862528a35f0bad5b0..6a3c977e109e741e6af1fb3c9e293b3e174bf5a6 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -353,7 +353,13 @@ stats_zero(void)
 
        for (dir = 0; dir <= 0xF; dir++) {
                struct counters *counters = counters_init(STATS_END);
+               struct stat st;
                fname = format("%s/%1x/stats", cache_dir, dir);
+               if (stat(fname, &st) != 0) {
+                       /* No point in trying to reset the stats file if it doesn't exist. */
+                       free(fname);
+                       continue;
+               }
                if (lockfile_acquire(fname, lock_staleness_limit)) {
                        stats_read(fname, counters);
                        for (i = 0; stats_info[i].message; i++) {