From 3bf0695a667f047451fae737bd88762d67cae3b5 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 27 Apr 2022 09:27:54 -0400 Subject: [PATCH] Island: Add comment/documentation about delete_file()'s idempotence --- .../cc/services/directory_file_storage_service.py | 1 + monkey/monkey_island/cc/services/i_file_storage_service.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/monkey/monkey_island/cc/services/directory_file_storage_service.py b/monkey/monkey_island/cc/services/directory_file_storage_service.py index f8aeebe21..a4be91522 100644 --- a/monkey/monkey_island/cc/services/directory_file_storage_service.py +++ b/monkey/monkey_island/cc/services/directory_file_storage_service.py @@ -54,6 +54,7 @@ class DirectoryFileStorageService(IFileStorageService): logger.debug(f"Deleting {safe_file_path}") safe_file_path.unlink() except FileNotFoundError: + # This method is idempotent. pass def _get_safe_file_path(self, unsafe_file_name: str): diff --git a/monkey/monkey_island/cc/services/i_file_storage_service.py b/monkey/monkey_island/cc/services/i_file_storage_service.py index 5903c07d1..31c49cd00 100644 --- a/monkey/monkey_island/cc/services/i_file_storage_service.py +++ b/monkey/monkey_island/cc/services/i_file_storage_service.py @@ -38,6 +38,9 @@ class IFileStorageService(metaclass=abc.ABCMeta): """ Delete a file + This method will delete the file specified by `unsafe_file_name`. This operation is + idempotent and will succeed if the file to be deleted does not exist. + :param unsafe_file_name: An unsanitized file name that identifies the file to be deleted """ pass