From: Joel Rosdahl Date: Thu, 13 Nov 2014 19:19:00 +0000 (+0100) Subject: Don't try to reset a non-existing stats file X-Git-Tag: v3.2~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c6209c69c7ad19e9025a63f3651544d9b122ef2;p=thirdparty%2Fccache.git Don't try to reset a non-existing stats file This avoids "No such file or directory" messages in the ccache log when the cache directory doesn't exist. --- diff --git a/lockfile.c b/lockfile.c index 84144a3ea..bce86df46 100644 --- a/lockfile.c +++ b/lockfile.c @@ -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 76cea8355..6a3c977e1 100644 --- 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++) {