diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 7 |
1 files changed, 3 insertions, 4 deletions
| @@ -1527,11 +1527,9 @@ d_char *dequeue(snac *snac, char *fn) | |||
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | 1529 | ||
| 1530 | static void _purge_file(const char *fn, int days) | 1530 | static void _purge_file(const char *fn, time_t mt) |
| 1531 | /* purge fn if it's older than days */ | 1531 | /* purge fn if it's older than days */ |
| 1532 | { | 1532 | { |
| 1533 | time_t mt = time(NULL) - days * 24 * 3600; | ||
| 1534 | |||
| 1535 | if (mtime(fn) < mt) { | 1533 | if (mtime(fn) < mt) { |
| 1536 | /* older than the minimum time: delete it */ | 1534 | /* older than the minimum time: delete it */ |
| 1537 | unlink(fn); | 1535 | unlink(fn); |
| @@ -1544,13 +1542,14 @@ static void _purge_subdir(snac *snac, const char *subdir, int days) | |||
| 1544 | /* purges all files in subdir older than days */ | 1542 | /* purges all files in subdir older than days */ |
| 1545 | { | 1543 | { |
| 1546 | if (days) { | 1544 | if (days) { |
| 1545 | time_t mt = time(NULL) - days * 24 * 3600; | ||
| 1547 | xs *spec = xs_fmt("%s/%s/" "*", snac->basedir, subdir); | 1546 | xs *spec = xs_fmt("%s/%s/" "*", snac->basedir, subdir); |
| 1548 | xs *list = xs_glob(spec, 0, 0); | 1547 | xs *list = xs_glob(spec, 0, 0); |
| 1549 | char *p, *v; | 1548 | char *p, *v; |
| 1550 | 1549 | ||
| 1551 | p = list; | 1550 | p = list; |
| 1552 | while (xs_list_iter(&p, &v)) | 1551 | while (xs_list_iter(&p, &v)) |
| 1553 | _purge_file(v, days); | 1552 | _purge_file(v, mt); |
| 1554 | } | 1553 | } |
| 1555 | } | 1554 | } |
| 1556 | 1555 | ||