From baaf3299cea973fec0558ac6f443751e23be79ec Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 19 Feb 2024 00:24:32 +0000 Subject: [PATCH] refactor(services): fix type annotation --- selfprivacy_api/services/moving.py | 6 +++--- selfprivacy_api/services/service.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/selfprivacy_api/services/moving.py b/selfprivacy_api/services/moving.py index ce13b30..e311c4f 100644 --- a/selfprivacy_api/services/moving.py +++ b/selfprivacy_api/services/moving.py @@ -19,7 +19,7 @@ def get_foldername(p: OwnedPath) -> str: return p.path.split("/")[-1] -def check_volume(volume: BlockDevice, space_needed: int) -> bool: +def check_volume(volume: BlockDevice, space_needed: int) -> None: # Check if there is enough space on the new volume if int(volume.fsavail) < space_needed: raise MoveError("Not enough space on the new volume.") @@ -55,7 +55,7 @@ def unbind_folders(owned_folders: List[OwnedPath]) -> None: def move_folders_to_volume( folders: List[OwnedPath], - old_volume: BlockDevice, + old_volume_name: str, # TODO: pass an actual validated block device new_volume: BlockDevice, job: Job, ) -> None: @@ -67,7 +67,7 @@ def move_folders_to_volume( for folder in folders: folder_name = get_foldername(folder) shutil.move( - f"/volumes/{old_volume}/{folder_name}", + f"/volumes/{old_volume_name}/{folder_name}", f"/volumes/{new_volume.name}/{folder_name}", ) progress = current_progress + folder_percentage diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 233e6e5..da3f5ca 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -353,6 +353,7 @@ class Service(ABC): Move a service to another volume. """ service_name = self.get_display_name() + # TODO: validate that this volume exists old_volume_name = self.get_drive() owned_folders = self.get_owned_folders()