split-secret/scripts/classes/Cleanup.py

37 lines
1.2 KiB
Python
Raw Normal View History

from .AbstractSplittedSecret import AbstractSplittedSecret
class Cleanup(AbstractSplittedSecret):
2022-12-09 20:10:12 +01:00
def __init__(self):
2022-12-09 13:22:57 +01:00
super(Cleanup, self).__init__()
2022-12-09 20:10:12 +01:00
def getAllFilePaths(self,file_type):
return [
self.getGroupFilesFolderPath(file_type),
self.getUserFilesFolderPath(file_type),
self.getAccumulatedFilePath(file_type)
]
2022-12-09 17:32:02 +01:00
def deleteAllFilesInFolder(self,folder_path):
try:
self.executeCommand('rm -v ' + folder_path + '*')
except:
pass
2022-12-09 20:10:12 +01:00
def deleteAllFiles(self,file_type):
for folder_path in self.getAllFilePaths(file_type):
2022-12-09 17:32:02 +01:00
self.deleteAllFilesInFolder(folder_path)
2022-12-09 13:22:57 +01:00
def deleteAllEncryptedFiles(self):
2022-12-09 17:32:02 +01:00
for folder_path in self.encrypted_files_folders:
self.deleteAllFilesInFolder(folder_path)
2022-12-09 18:16:31 +01:00
def cleanupForUser(self,user):
2022-12-09 23:43:28 +01:00
try:
self.executeCommand('find "' + self.getFolderPath("encrypted") + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
except:
pass
self.deleteAllFiles("decrypted")
2022-12-09 17:32:02 +01:00
def deleteAll(self):
2022-12-09 20:10:12 +01:00
self.deleteAllFiles("encrypted")
self.deleteAllFiles("decrypted")