Implemented the actual deleting part

This commit is contained in:
Mike 2019-02-27 16:51:43 -08:00
parent 6b40527e09
commit 4a975b38f1

View File

@ -3,6 +3,7 @@
import datetime import datetime
import os import os
import shutil
import sys import sys
import yaml import yaml
@ -104,8 +105,14 @@ class BackupRotator:
for purge_index in range(purge_count): for purge_index in range(purge_count):
item_to_purge = self.pick_item_to_purge(children) item_to_purge = self.pick_item_to_purge(children)
self.log("Purging item:", item_to_purge)
children.remove(item_to_purge) children.remove(item_to_purge)
self.log("Purging item:", item_to_purge)
if os.path.isfile(item_to_purge):
os.remove(item_to_purge)
elif os.path.isdir(item_to_purge):
shutil.rmtree(item_to_purge)
else:
raise Exception("Don't know how to remove this item: " + str(item_to_purge))
def gather_rotation_candidates(self, path): def gather_rotation_candidates(self, path):