aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2020-12-11 17:11:09 -0500
committerRyan Kavanagh <rak@rak.ac>2020-12-11 17:11:20 -0500
commite8267a75ceef721715de17e61f40b65eb93f8ca7 (patch)
tree90d51b013491264e957ec16aec3ecb9515a877db
parentHandle different md5sum implementations (diff)
Keep files larger than max_size for 7 daysHEADmaster
-rw-r--r--README5
-rw-r--r--cleanup.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/README b/README
index dfc49b2..c28bd3b 100644
--- a/README
+++ b/README
@@ -3,8 +3,9 @@ Most of these were uploaded to share something on IRC / email / IM, and aren't
needed after some number of days.
To address this, I wrote a small garbage collector in C. Its file retention
-period is shamelessly stolen from the kind folks at http://0x0.st/ and
-https://ttm.sh/ .
+period is shamelessly stolen from the kind folks at <http://0x0.st/> and
+<https://ttm.sh/>, with the exception that files larger than max_size are kept
+for a fxed number of days before being deleted.
SETUP:
diff --git a/cleanup.c b/cleanup.c
index d308a12..62b0dd4 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -29,6 +29,7 @@
#include <time.h>
#include <unistd.h>
+const double bigd = 7.0;
const double mind = 30.0;
const double maxd = 90.0;
const double max_size = 33554432; // 32MB
@@ -82,8 +83,11 @@ main(int argc, char * const argv[])
break;
}
file_age = difftime(curr_time, attr.st_mtime) / 86400.0;
- cutoff = mind + (mind - maxd) *
- pow((double) attr.st_size / (double) max_size - 1, 3.0);
+ if (attr.st_size > max_size)
+ cutoff = bigd;
+ else
+ cutoff = mind + (mind - maxd) *
+ pow((double) attr.st_size / (double) max_size - 1, 3.0);
if (verbose)
printf("%s age %fd cuttoff %fd size %lldB\n",
node->fts_path, file_age, cutoff, attr.st_size);