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: v4.0~726 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b942c13e12c30d3ee9d5c14d04867b8f8084ca8b;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. (cherry picked from commit e1fc59223518c53ab227d224a36fe2eeead127eb) --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 51be84429..a0dc5a9f7 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -275,6 +275,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; @@ -472,7 +476,7 @@ clean_up_internal_tempdir(void) { time_t now = time(NULL); auto st = Stat::stat(g_config.cache_dir(), Stat::OnError::log); - if (!st || st.mtime() + 3600 >= now) { + if (!st || st.mtime() + k_internal_tempdir_cleanup_interval >= now) { // No cleanup needed. return; } @@ -492,7 +496,7 @@ clean_up_internal_tempdir(void) char* path = format("%s/%s", temp_dir(), entry->d_name); st = Stat::lstat(path, Stat::OnError::log); - if (st && st.mtime() + 3600 < now) { + if (st && st.mtime() + k_internal_tempdir_cleanup_interval < now) { tmp_unlink(path); } free(path);