From ce0affb1ed76d05408b7f71055f1026f98700c37 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 28 Sep 2022 15:39:14 +0530 Subject: [PATCH] Island: Implement delete_files_by_pattern() in LocalStorageFileRepository --- .../cc/repository/local_storage_file_repository.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/monkey/monkey_island/cc/repository/local_storage_file_repository.py b/monkey/monkey_island/cc/repository/local_storage_file_repository.py index 58fd20bdb..840ab1701 100644 --- a/monkey/monkey_island/cc/repository/local_storage_file_repository.py +++ b/monkey/monkey_island/cc/repository/local_storage_file_repository.py @@ -1,3 +1,4 @@ +import glob import logging import shutil from pathlib import Path @@ -55,6 +56,10 @@ class LocalStorageFileRepository(IFileRepository): f'Error retrieving file "{unsafe_file_name}" from the repository: {err}' ) + def delete_files_by_pattern(self, file_name_pattern: str): + for file_name in glob.iglob(f"{self._storage_directory}/{file_name_pattern}"): + self.delete_file(file_name) + def delete_file(self, unsafe_file_name: str): try: safe_file_path = self._get_safe_file_path(unsafe_file_name)