]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Ignore .nfs* files when cleaning up
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 19 Jul 2010 09:54:02 +0000 (11:54 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 19 Jul 2010 09:54:02 +0000 (11:54 +0200)
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.

cleanup.c
test.sh

index e33accae6db1de10cc113f25d04fe5f72b5d2875..acd6baaada4b9eac86bb7ec07ac244bf27bc7531 100644 (file)
--- 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 d07b95f2f8b64fe24b6f8975b6c7ad07ca591d79..62d35db46d6d5834f27e6bbb945e2630a8e4119d 100755 (executable)
--- 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
 }
 
 ######################################################################