From b89dea3c6960c9da6f242855e339971835738a20 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 12 Jul 2019 20:55:23 +0100 Subject: [PATCH] Archive to directory --- media.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/media.py b/media.py index 3a2d6b7b..00cb31b1 100644 --- a/media.py +++ b/media.py @@ -17,6 +17,7 @@ import datetime from auth import createPassword from shutil import copyfile from shutil import rmtree +from shutil import move def getImageHash(imageFilename: str) -> str: return blurencode(numpy.array(Image.open(imageFilename).convert("RGB"))) @@ -97,7 +98,7 @@ def removeAttachment(baseDir: str,httpPrefix: str,domain: str,postJson: {}): os.remove(mediaFilename) postJson['attachment']=[] -def archiveMedia(baseDir: str,maxWeeks=4) -> None: +def archiveMedia(baseDir: str,archiveDirectory: str,maxWeeks=4) -> None: """Any media older than the given number of weeks gets archived """ currTime=datetime.datetime.utcnow() @@ -107,5 +108,8 @@ def archiveMedia(baseDir: str,maxWeeks=4) -> None: for subdir, dirs, files in os.walk(baseDir+'/media'): for weekDir in dirs: if int(weekDir)