diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-01-10 18:08:42 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-01-10 18:08:42 +0000 |
commit | 10d86f76150bbb4fd37a17cc6f8c307c766d532b (patch) | |
tree | e01ac9b95bc6da9b383661726663fedd7b9f715a /src/or | |
parent | 2ac1e362484f8418ca3a3f0fda419c5205209e75 (diff) | |
download | tor-10d86f76150bbb4fd37a17cc6f8c307c766d532b.tar.gz tor-10d86f76150bbb4fd37a17cc6f8c307c766d532b.zip |
r17558@catbus: nickm | 2008-01-10 13:07:41 -0500
If we do not serve v2 directory info, and our cached v2 networkstatus files are very old, remove them. If the directory is old, remove that too. (We already did this for obsolete routers files.)
svn:r13096
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/networkstatus.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 67e34a7786..b406166023 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -122,15 +122,29 @@ router_reload_v2_networkstatus(void) struct stat st; char *s; char *filename = get_datadir_fname("cached-status"); + int maybe_delete = !directory_caches_v2_dir_info(get_options()); + time_t now = time(NULL); if (!networkstatus_v2_list) networkstatus_v2_list = smartlist_create(); entries = tor_listdir(filename); - tor_free(filename); - if (!entries) /* dir doesn't exist */ + if (!entries) { /* dir doesn't exist */ + tor_free(filename); return 0; + } else if (!smartlist_len(entries) && maybe_delete) { + rmdir(filename); + tor_free(filename); + return 0; + } + tor_free(filename); SMARTLIST_FOREACH(entries, const char *, fn, { char buf[DIGEST_LEN]; + if (maybe_delete) { + filename = get_datadir_fname2("cached-status", fn); + remove_file_if_very_old(filename, now); + tor_free(filename); + continue; + } if (strlen(fn) != HEX_DIGEST_LEN || base16_decode(buf, sizeof(buf), fn, strlen(fn))) { log_info(LD_DIR, |