forked from p15670423/monkey
Island: Implement delete_files_by_pattern() in LocalStorageFileRepository
This commit is contained in:
parent
d9b55a5c21
commit
ce0affb1ed
|
@ -1,3 +1,4 @@
|
||||||
|
import glob
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -55,6 +56,10 @@ class LocalStorageFileRepository(IFileRepository):
|
||||||
f'Error retrieving file "{unsafe_file_name}" from the repository: {err}'
|
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):
|
def delete_file(self, unsafe_file_name: str):
|
||||||
try:
|
try:
|
||||||
safe_file_path = self._get_safe_file_path(unsafe_file_name)
|
safe_file_path = self._get_safe_file_path(unsafe_file_name)
|
||||||
|
|
Loading…
Reference in New Issue