From: Joel Rosdahl Date: Mon, 19 Jul 2010 09:54:02 +0000 (+0200) Subject: Ignore .nfs* files when cleaning up X-Git-Tag: v3.1~142 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56b8c877b0e5c4e28bb38d8cfa9573c1633dd1f4;p=thirdparty%2Fccache.git Ignore .nfs* files when cleaning up Such files are left by an NFS server for open but deleted files and will thus mess up ccache's "files in cache" counter if not ignored. --- diff --git a/cleanup.c b/cleanup.c index e33accae6..acd6baaad 100644 --- a/cleanup.c +++ b/cleanup.c @@ -70,6 +70,11 @@ static void traverse_fn(const char *fname, struct stat *st) goto out; } + if (strncmp(p, ".nfs", 4) == 0) { + /* Ignore temporary NFS files that may be left for open but deleted files. */ + goto out; + } + if (strstr(p, ".tmp.") != NULL) { /* delete any tmp files older than 1 hour */ if (st->st_mtime + 3600 < time(NULL)) { diff --git a/test.sh b/test.sh index d07b95f2f..62d35db46 100755 --- a/test.sh +++ b/test.sh @@ -1505,6 +1505,14 @@ cleanup_suite() { test_failed "$CCACHE_DIR/a/abcd.tmp.unknown not removed" fi checkstat 'files in cache' 0 + + testname="ignore .nfs* files" + prepare_cleanup_test $CCACHE_DIR/a + touch $CCACHE_DIR/a/.nfs0123456789 + $CCACHE -F 0 -M 0 >/dev/null + $CCACHE -c >/dev/null + checkfilecount 1 '.nfs*' $CCACHE_DIR + checkstat 'files in cache' 30 } ######################################################################