diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-10-14 00:13:06 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-10-14 00:13:06 +0000 |
commit | 09dfe31ff469c0944188583307dde87d467a9ca0 (patch) | |
tree | 434f237cfbc0689a05bd54ef1a5080ecbd0511fd /src/or/config.c | |
parent | 1b45314775516781ca4c15cafbb01847e19f2171 (diff) | |
download | tor-09dfe31ff469c0944188583307dde87d467a9ca0.tar.gz tor-09dfe31ff469c0944188583307dde87d467a9ca0.zip |
r15750@catbus: nickm | 2007-10-13 20:06:47 -0400
Eventually delete the obsolete cached-routers and cached-routers.new files, so they don't sit around on disk forever.
svn:r11918
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index 4b548e3392..0bf88b2e44 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -4526,6 +4526,23 @@ or_state_save(time_t now) return 0; } +/** Given a file name check to see whether the file exists but has not been + * modified for a very long time. If so, remove it. */ +void +remove_file_if_very_old(const char *fname, time_t now) +{ +#define VERY_OLD_FILE_AGE (28*24*60*60) + struct stat st; + + if (stat(fname, &st)==0 && st.st_mtime < now-VERY_OLD_FILE_AGE) { + char buf[ISO_TIME_LEN+1]; + format_local_iso_time(buf, st.st_mtime); + log_notice(LD_GENERAL, "Obsolete file %s hasn't been modified since %s. " + "Removing it.", fname, buf); + unlink(fname); + } +} + /** Helper to implement GETINFO functions about configuration variables (not * their values). Given a "config/names" question, set *<b>answer</b> to a * new string describing the supported configuration variables and their |