]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Increase interval for cleaning up $CCACHE_DIR/tmp to 2 days
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Oct 2019 18:04:01 +0000 (20:04 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Oct 2019 18:12:09 +0000 (20:12 +0200)
This will reduce problems when adjusting system time; see #480.

src/ccache.c

index edfc8ca52fd032e83a04370c05d3eb83849e50a9..5fa817e741e1939ef1ff19269069268f686bcb10 100644 (file)
@@ -280,6 +280,10 @@ struct pending_tmp_file {
 // Temporary files to remove at program exit.
 static struct pending_tmp_file *pending_tmp_files = NULL;
 
+// How often (in seconds) to scan $CCACHE_DIR/tmp for left-over temporary
+// files.
+const int k_internal_tempdir_cleanup_interval = 2 * 24 * 60 * 60; // 2 days
+
 #ifndef _WIN32
 static sigset_t fatal_signal_set;
 
@@ -480,7 +484,8 @@ clean_up_internal_tempdir(void)
 {
        time_t now = time(NULL);
        struct stat st;
-       if (x_stat(conf->cache_dir, &st) != 0 || st.st_mtime + 3600 >= now) {
+       if (x_stat(conf->cache_dir, &st) != 0
+                       || st.st_mtime + k_internal_tempdir_cleanup_interval >= now) {
                // No cleanup needed.
                return;
        }
@@ -499,7 +504,8 @@ clean_up_internal_tempdir(void)
                }
 
                char *path = format("%s/%s", temp_dir(), entry->d_name);
-               if (x_lstat(path, &st) == 0 && st.st_mtime + 3600 < now) {
+               if (x_lstat(path, &st) == 0
+                               && st.st_mtime + k_internal_tempdir_cleanup_interval < now) {
                        tmp_unlink(path);
                }
                free(path);