mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 17:26:46 +00:00
refactor(services): make a foldermove from owned path
This commit is contained in:
parent
ad66513f27
commit
238a656cd9
|
@ -1,5 +1,6 @@
|
||||||
"""Generic handler for moving services"""
|
"""Generic handler for moving services"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import pathlib
|
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.block_devices import BlockDevice
|
||||||
from selfprivacy_api.utils import ReadUserData, WriteUserData
|
from selfprivacy_api.utils import ReadUserData, WriteUserData
|
||||||
from selfprivacy_api.services.service import Service, ServiceStatus
|
from selfprivacy_api.services.service import Service, ServiceStatus
|
||||||
|
from selfprivacy_api.services.owned_path import OwnedPath
|
||||||
|
|
||||||
|
|
||||||
class FolderMoveNames(BaseModel):
|
class FolderMoveNames(BaseModel):
|
||||||
|
@ -19,6 +21,19 @@ class FolderMoveNames(BaseModel):
|
||||||
owner: str
|
owner: str
|
||||||
group: 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()
|
@huey.task()
|
||||||
def move_service(
|
def move_service(
|
||||||
|
|
Loading…
Reference in a new issue