Implemented cleanup for user

This commit is contained in:
Kevin Veen-Birkenbach 2022-12-09 18:16:31 +01:00
parent 550b689c12
commit 4860282de1
2 changed files with 11 additions and 2 deletions

View File

@ -21,6 +21,12 @@ class Cleanup(AbstractSplittedSecret):
for folder_path in self.encrypted_files_folders: for folder_path in self.encrypted_files_folders:
self.deleteAllFilesInFolder(folder_path) self.deleteAllFilesInFolder(folder_path)
def cleanupForUser(self,user):
self.executeCommand('find "' + self.encrypted_folder + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
print(self.getCommandString())
print(self.getOutputString())
def deleteAll(self): def deleteAll(self):
self.deleteAllEncryptedFiles() self.deleteAllEncryptedFiles()
self.deleteAllDecryptedFiles() self.deleteAllDecryptedFiles()

View File

@ -9,12 +9,15 @@ if __name__ == '__main__':
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=range(1,9)) parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=range(1,9))
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False) parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
parser.add_argument('--master-password',type=str, dest='master_password',required=False) parser.add_argument('--master-password',type=str, dest='master_password',required=False)
parser.add_argument('--user',type=int, dest='user',choices=range(1,9),required=False)
args = parser.parse_args() args = parser.parse_args()
if args.mode == 'cleanup': if args.mode == 'cleanup':
cleanup = Cleanup() cleanup = Cleanup()
if args.user is None:
cleanup.deleteAll() cleanup.deleteAll()
exit() exit()
cleanup.cleanupForUser(args.user)
if args.mode == 'generate': if args.mode == 'generate':
if args.master_password is None: if args.master_password is None: