Island: raise RemovalError in Local...FileRepository.delete_all_files()

This commit is contained in:
Mike Salvatore 2022-06-21 13:28:44 -04:00
parent da1339e410
commit 21be5fc2be
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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}")