// 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;
{
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;
}
}
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);