1
0
Fork 0
forked from mia/0x0
This commit is contained in:
Martin Herkt 2016-11-01 05:17:54 +01:00
commit 56f0295be2
No known key found for this signature in database
GPG key ID: C24B9CD04DC6AE7F
11 changed files with 711 additions and 0 deletions

23
cleanup.py Executable file
View file

@ -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)