summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2022-11-25 11:15:09 +0100
committerGravatar default2022-11-25 11:15:09 +0100
commitb79241701385c33b58359adfa20bbadb643b86b9 (patch)
treeb556918d9db04520f5a84e9fa418f4665d78a0ae /data.c
parentUpdated documentation. (diff)
downloadsnac2-b79241701385c33b58359adfa20bbadb643b86b9.tar.gz
snac2-b79241701385c33b58359adfa20bbadb643b86b9.tar.xz
snac2-b79241701385c33b58359adfa20bbadb643b86b9.zip
Also purge the hidden/ user directory.
Diffstat (limited to 'data.c')
-rw-r--r--data.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/data.c b/data.c
index 1dd2c43..bcfdd9b 100644
--- a/data.c
+++ b/data.c
@@ -1482,7 +1482,7 @@ static void _purge_subdir(snac *snac, const char *subdir, int days)
1482{ 1482{
1483 if (days) { 1483 if (days) {
1484 time_t mt = time(NULL) - days * 24 * 3600; 1484 time_t mt = time(NULL) - days * 24 * 3600;
1485 xs *spec = xs_fmt("%s/%s/" "*.json", snac->basedir, subdir); 1485 xs *spec = xs_fmt("%s/%s/" "*", snac->basedir, subdir);
1486 xs *list = xs_glob(spec, 0, 0); 1486 xs *list = xs_glob(spec, 0, 0);
1487 char *p, *v; 1487 char *p, *v;
1488 1488
@@ -1498,13 +1498,14 @@ static void _purge_subdir(snac *snac, const char *subdir, int days)
1498} 1498}
1499 1499
1500 1500
1501void purge(snac *snac) 1501void purge_user(snac *snac)
1502/* do the purge */ 1502/* do the purge for this user */
1503{ 1503{
1504 int days; 1504 int days;
1505 1505
1506 days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days")); 1506 days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days"));
1507 _purge_subdir(snac, "timeline", days); 1507 _purge_subdir(snac, "timeline", days);
1508 _purge_subdir(snac, "hidden", days);
1508 1509
1509 days = xs_number_get(xs_dict_get(srv_config, "local_purge_days")); 1510 days = xs_number_get(xs_dict_get(srv_config, "local_purge_days"));
1510 _purge_subdir(snac, "local", days); 1511 _purge_subdir(snac, "local", days);
@@ -1521,7 +1522,7 @@ void purge_all(void)
1521 p = list; 1522 p = list;
1522 while (xs_list_iter(&p, &uid)) { 1523 while (xs_list_iter(&p, &uid)) {
1523 if (user_open(&snac, uid)) { 1524 if (user_open(&snac, uid)) {
1524 purge(&snac); 1525 purge_user(&snac);
1525 user_free(&snac); 1526 user_free(&snac);
1526 } 1527 }
1527 } 1528 }