Island: Ignore exception in delete_file() if file not found
This commit is contained in:
parent
8f7215034d
commit
a0b4dc1bcb
|
@ -40,7 +40,10 @@ class DirectoryFileStorageService(IFileStorageService):
|
|||
def delete_file(self, unsafe_file_name: str):
|
||||
safe_file_path = self._get_safe_file_path(unsafe_file_name)
|
||||
|
||||
safe_file_path.unlink()
|
||||
try:
|
||||
safe_file_path.unlink()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def _get_safe_file_path(self, unsafe_file_name: str):
|
||||
# Remove any path information from the file name.
|
||||
|
|
|
@ -119,3 +119,10 @@ def test_remove_all_files__skip_directories(tmp_path):
|
|||
|
||||
for file in tmp_path.iterdir():
|
||||
assert file.name == test_dir.name
|
||||
|
||||
|
||||
def test_remove_nonexistant_file(tmp_path):
|
||||
fss = DirectoryFileStorageService(tmp_path)
|
||||
|
||||
# This test will fail if this call raises an exception.
|
||||
fss.delete_file("nonexistant_file.txt")
|
||||
|
|
Loading…
Reference in New Issue