Refactors Services and Initial Test Implementation
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
import logging
|
||||
|
||||
from storage_service.depends.depend_s3_service import (
|
||||
dependency_storage_service,
|
||||
)
|
||||
from storage_service.utils.enums.file_type import FileType
|
||||
from storage_service.utils.file_name_hash import file_name_hash
|
||||
from storage_service.utils.file.file_hash_generator import generate_file_hash
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def storage_file_worker(username: str, file_postfix: str) -> None:
|
||||
dependency_storage_service().process_file(file_name_hash(username, file_postfix))
|
||||
storage_service = dependency_storage_service()
|
||||
|
||||
file_name = generate_file_hash(username, file_postfix)
|
||||
try:
|
||||
stats = storage_service.process_file(file_name)
|
||||
|
||||
print(
|
||||
f"File processed: {file_name} - "
|
||||
f"Previous Size: {stats["previous_size"]/1_000}kb - "
|
||||
f"New Size: {stats["current_size"]/1_000}kb"
|
||||
)
|
||||
except Exception as e:
|
||||
print(
|
||||
f"Error processing file: {e}."
|
||||
f" Deleting file: {file_name}."
|
||||
)
|
||||
|
||||
storage_service.delete_file(file_name)
|
||||
|
||||
Reference in New Issue
Block a user