refactor(services): fix type annotation

This commit is contained in:
Houkime 2024-02-19 00:24:32 +00:00
parent f059c83b57
commit baaf3299ce
2 changed files with 4 additions and 3 deletions

View file

@ -19,7 +19,7 @@ def get_foldername(p: OwnedPath) -> str:
return p.path.split("/")[-1] 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 # Check if there is enough space on the new volume
if int(volume.fsavail) < space_needed: if int(volume.fsavail) < space_needed:
raise MoveError("Not enough space on the new volume.") 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( def move_folders_to_volume(
folders: List[OwnedPath], folders: List[OwnedPath],
old_volume: BlockDevice, old_volume_name: str, # TODO: pass an actual validated block device
new_volume: BlockDevice, new_volume: BlockDevice,
job: Job, job: Job,
) -> None: ) -> None:
@ -67,7 +67,7 @@ def move_folders_to_volume(
for folder in folders: for folder in folders:
folder_name = get_foldername(folder) folder_name = get_foldername(folder)
shutil.move( shutil.move(
f"/volumes/{old_volume}/{folder_name}", f"/volumes/{old_volume_name}/{folder_name}",
f"/volumes/{new_volume.name}/{folder_name}", f"/volumes/{new_volume.name}/{folder_name}",
) )
progress = current_progress + folder_percentage progress = current_progress + folder_percentage

View file

@ -353,6 +353,7 @@ class Service(ABC):
Move a service to another volume. Move a service to another volume.
""" """
service_name = self.get_display_name() service_name = self.get_display_name()
# TODO: validate that this volume exists
old_volume_name = self.get_drive() old_volume_name = self.get_drive()
owned_folders = self.get_owned_folders() owned_folders = self.get_owned_folders()