From: Joel Rosdahl Date: Tue, 22 Oct 2019 18:04:01 +0000 (+0200) Subject: Increase interval for cleaning up $CCACHE_DIR/tmp to 2 days X-Git-Tag: v3.7.5~5 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1fc59223518c53ab227d224a36fe2eeead127eb;p=thirdparty%2Fccache.git Increase interval for cleaning up $CCACHE_DIR/tmp to 2 days This will reduce problems when adjusting system time; see #480. --- diff --git a/src/ccache.c b/src/ccache.c index edfc8ca52..5fa817e74 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -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);