summaryrefslogtreecommitdiff
path: root/cleanup.py
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2016-11-01 05:17:54 +0100
committerMartin Herkt <lachs0r@srsfckn.biz>2016-11-01 05:25:58 +0100
commit56f0295be203771f59e94162b62fa17d4fea54a3 (patch)
tree554f6dcf9707a6f50a61f0b6b6566d731a54c4fe /cleanup.py
init
Diffstat (limited to 'cleanup.py')
-rwxr-xr-xcleanup.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/cleanup.py b/cleanup.py
new file mode 100755
index 0000000..401140a
--- /dev/null
+++ b/cleanup.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+import os, sys, time, datetime
+from fhost import app
+
+os.chdir(os.path.dirname(sys.argv[0]))
+os.chdir(app.config["FHOST_STORAGE_PATH"])
+
+files = [f for f in os.listdir(".")]
+
+maxs = app.config["MAX_CONTENT_LENGTH"]
+mind = 30
+maxd = 365
+
+for f in files:
+ stat = os.stat(f)
+ systime = time.time()
+ age = datetime.timedelta(seconds = systime - stat.st_mtime).days
+
+ maxage = mind + (-maxd + mind) * (stat.st_size / maxs - 1) ** 3
+
+ if age >= maxage:
+ os.remove(f)