Island: Implement delete_files_by_pattern() in LocalStorageFileRepository

This commit is contained in:
Shreya Malviya 2022-09-28 15:39:14 +05:30
parent d9b55a5c21
commit ce0affb1ed
1 changed files with 5 additions and 0 deletions

View File

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