mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
refactor(services): fix type annotation
This commit is contained in:
parent
f059c83b57
commit
baaf3299ce
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue