From 1b2ca74b9f5e9fdcb9883b539718a96b86dc2e13 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 8 Jun 2022 10:34:46 -0400 Subject: [PATCH] Island: Add TODO about IFileRepository FileNotFoundErrors --- .../repository/file_storage/local_storage_file_repository.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py b/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py index 45f01b81b..4202496ad 100644 --- a/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py +++ b/monkey/monkey_island/cc/repository/file_storage/local_storage_file_repository.py @@ -44,6 +44,10 @@ class LocalStorageFileRepository(IFileRepository): logger.debug(f"Opening {safe_file_path}") return open(safe_file_path, "rb") except OSError as err: + # TODO: The interface should make a destinction between file not found and an error when + # retrieving a file that should exist. The built-in `FileNotFoundError` is not + # sufficient because it inherits from `OSError` and the interface does not + # guarantee that the file is stored on the local file system. raise FileRetrievalError(f"Failed to retrieve file {safe_file_path}: {err}") from err def delete_file(self, unsafe_file_name: str):