Island: Rename _file_storage_service -> _file_repository

This commit is contained in:
Mike Salvatore 2022-07-26 12:18:20 -04:00
parent 2d86f1a3f1
commit b5691a33f6
2 changed files with 8 additions and 8 deletions

View File

@ -15,13 +15,13 @@ class PBAFileDownload(AbstractResource):
File download endpoint used by monkey to download user's PBA file File download endpoint used by monkey to download user's PBA file
""" """
def __init__(self, file_storage_service: IFileRepository): def __init__(self, file_repository: IFileRepository):
self._file_storage_service = file_storage_service self._file_repository = file_repository
# Used by monkey. can't secure. # Used by monkey. can't secure.
def get(self, filename: str): def get(self, filename: str):
try: try:
file = self._file_storage_service.open_file(filename) file = self._file_repository.open_file(filename)
# `send_file()` handles the closing of the open file. # `send_file()` handles the closing of the open file.
return send_file(file, mimetype="application/octet-stream") return send_file(file, mimetype="application/octet-stream")

View File

@ -32,10 +32,10 @@ class FileUpload(AbstractResource):
def __init__( def __init__(
self, self,
file_storage_repository: IFileRepository, file_repository: IFileRepository,
agent_configuration_repository: IAgentConfigurationRepository, agent_configuration_repository: IAgentConfigurationRepository,
): ):
self._file_storage_service = file_storage_repository self._file_repository = file_repository
self._agent_configuration_repository = agent_configuration_repository self._agent_configuration_repository = agent_configuration_repository
# NOTE: None of these methods are thread-safe. Don't forget to fix that when this becomes a # NOTE: None of these methods are thread-safe. Don't forget to fix that when this becomes a
@ -64,7 +64,7 @@ class FileUpload(AbstractResource):
filename = agent_configuration.custom_pbas.windows_filename filename = agent_configuration.custom_pbas.windows_filename
try: try:
file = self._file_storage_service.open_file(filename) file = self._file_repository.open_file(filename)
# `send_file()` handles the closing of the open file. # `send_file()` handles the closing of the open file.
return send_file(file, mimetype="application/octet-stream") return send_file(file, mimetype="application/octet-stream")
@ -87,7 +87,7 @@ class FileUpload(AbstractResource):
file_storage = next(request.files.values()) # For now, assume there's only one file file_storage = next(request.files.values()) # For now, assume there's only one file
safe_filename = sanitize_filename(file_storage.filename) safe_filename = sanitize_filename(file_storage.filename)
self._file_storage_service.save_file(safe_filename, file_storage.stream) self._file_repository.save_file(safe_filename, file_storage.stream)
try: try:
self._update_config(target_os, safe_filename) self._update_config(target_os, safe_filename)
except Exception as err: except Exception as err:
@ -129,7 +129,7 @@ class FileUpload(AbstractResource):
filename = original_agent_configuration.custom_pbas.windows_filename filename = original_agent_configuration.custom_pbas.windows_filename
try: try:
self._file_storage_service.delete_file(filename) self._file_repository.delete_file(filename)
except Exception as err: except Exception as err:
# Roll back the entire transaction if part of it failed. # Roll back the entire transaction if part of it failed.
self._agent_configuration_repository.store_configuration(original_agent_configuration) self._agent_configuration_repository.store_configuration(original_agent_configuration)