diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index 046e79efb..25b54cb28 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -1,6 +1,5 @@ import copy import logging -import os from pathlib import Path import flask_restful @@ -84,16 +83,7 @@ class FileUpload(flask_restful.Resource): ) filename = ConfigService.get_config_value(filename_path) if filename: - file_path = Path(PostBreachFilesService.get_custom_pba_directory()).joinpath(filename) - FileUpload._delete_file(file_path) + PostBreachFilesService.remove_file(filename) ConfigService.set_config_value(filename_path, "") return {} - - @staticmethod - def _delete_file(file_path): - try: - if os.path.exists(file_path): - os.remove(file_path) - except OSError as e: - LOG.error("Couldn't remove previously uploaded post breach files: %s" % e) diff --git a/monkey/monkey_island/cc/services/post_breach_files.py b/monkey/monkey_island/cc/services/post_breach_files.py index a56c585de..d7eeb9306 100644 --- a/monkey/monkey_island/cc/services/post_breach_files.py +++ b/monkey/monkey_island/cc/services/post_breach_files.py @@ -36,12 +36,12 @@ class PostBreachFilesService: PBA_LINUX_FILENAME_PATH ) if linux_filename: - PostBreachFilesService._remove_file(linux_filename) + PostBreachFilesService.remove_file(linux_filename) if windows_filename: - PostBreachFilesService._remove_file(windows_filename) + PostBreachFilesService.remove_file(windows_filename) @staticmethod - def _remove_file(file_name): + def remove_file(file_name): file_path = os.path.join(PostBreachFilesService.get_custom_pba_directory(), file_name) try: if os.path.exists(file_path):