diff options
author | default <nobody@localhost> | 2022-10-04 18:46:12 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-10-04 18:46:12 +0200 |
commit | ae06064e4d77d10b82c6061427dcc01d942b1dd8 (patch) | |
tree | 6da9cbb635f377f908e2a442cb122dc6a8f42b8a /data.c | |
parent | 5192e28444a3e1a613440ef6813cb978c36d2948 (diff) |
New command-line option purge.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -996,3 +996,36 @@ d_char *dequeue(snac *snac, char *fn) return obj; } + + +void purge(snac *snac) +/* do the purge */ +{ + int tpd = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days")); + time_t mt = time(NULL) - tpd * 24 * 3600; + char *p, *v; + + xs *t_spec = xs_fmt("%s/timeline/" "*.json", snac->basedir); + xs *t_list = xs_glob(t_spec, 0, 0); + + p = t_list; + while (xs_list_iter(&p, &v)) { + if (mtime(v) < mt) { + /* older than the minimum time: delete it */ + unlink(v); + snac_debug(snac, 1, xs_fmt("purged %s", v)); + } + } + + xs *a_spec = xs_fmt("%s/actors/" "*.json", snac->basedir); + xs *a_list = xs_glob(a_spec, 0, 0); + + p = a_list; + while (xs_list_iter(&p, &v)) { + if (mtime(v) < mt) { + /* older than the minimum time: delete it */ + unlink(v); + snac_debug(snac, 1, xs_fmt("purged %s", v)); + } + } +} |