diff --git a/monkey/monkey_island/cc/repository/file_storage/i_file_repository.py b/monkey/monkey_island/cc/repository/file_storage/i_file_repository.py index cfebe5c05..c0897aa1a 100644 --- a/monkey/monkey_island/cc/repository/file_storage/i_file_repository.py +++ b/monkey/monkey_island/cc/repository/file_storage/i_file_repository.py @@ -56,5 +56,7 @@ class IFileRepository(metaclass=abc.ABCMeta): def delete_all_files(self): """ Delete all files that have been stored using this service. + + :raises RemovalError: If an error was encountered while attempting to remove a file """ pass diff --git a/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py b/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py index d18e029f4..564582c76 100644 --- a/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py +++ b/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py @@ -82,6 +82,9 @@ class LocalStorageFileRepository(IFileRepository): return safe_file_path def delete_all_files(self): - for file in get_all_regular_files_in_directory(self._storage_directory): - logger.debug(f"Deleting {file}") - file.unlink() + try: + for file in get_all_regular_files_in_directory(self._storage_directory): + logger.debug(f"Deleting {file}") + file.unlink() + except Exception as err: + raise RemovalError(f"Error while attempting to clear the repository: {err}")