refactor(services): make a foldermove from owned path

restic-rewrite-api
Houkime 2023-04-17 16:01:51 +00:00
parent ad66513f27
commit 238a656cd9
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
"""Generic handler for moving services"""
from __future__ import annotations
import subprocess
import time
import pathlib
@ -11,6 +12,7 @@ from selfprivacy_api.utils.huey import huey
from selfprivacy_api.utils.block_devices import BlockDevice
from selfprivacy_api.utils import ReadUserData, WriteUserData
from selfprivacy_api.services.service import Service, ServiceStatus
from selfprivacy_api.services.owned_path import OwnedPath
class FolderMoveNames(BaseModel):
@ -19,6 +21,19 @@ class FolderMoveNames(BaseModel):
owner: str
group: str
@staticmethod
def from_owned_path(path: OwnedPath) -> FolderMoveNames:
return FolderMoveNames(
name=FolderMoveNames.get_foldername(),
bind_location=path.path,
owner=path.owner,
group=path.group,
)
@staticmethod
def get_foldername(path: str) -> str:
return path.split("/")[-1]
@huey.task()
def move_service(