forked from p15670423/monkey
Island: Modify delete_files_by_pattern -> delete_files_by_regex in LocalStorageFileRepository
This commit is contained in:
parent
c5d26749b7
commit
1c486c6571
|
@ -1,5 +1,6 @@
|
|||
import glob
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import BinaryIO
|
||||
|
@ -56,9 +57,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_files_by_regex(self, file_name_regex: re.Pattern):
|
||||
for file_name in os.listdir(self._storage_directory):
|
||||
if re.match(file_name_regex, file_name):
|
||||
self.delete_file(file_name)
|
||||
|
||||
def delete_file(self, unsafe_file_name: str):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue