mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
doc(services): explain the Owned Path reason d'etre after trying to remove it
This commit is contained in:
parent
eeef2891c9
commit
fd43a6ccf1
|
@ -14,8 +14,21 @@ class BindError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# May be deprecated because of Binds
|
|
||||||
class OwnedPath(BaseModel):
|
class OwnedPath(BaseModel):
|
||||||
|
"""
|
||||||
|
A convenient interface for explicitly defining ownership of service folders.
|
||||||
|
One overrides Service.get_owned_paths() for this.
|
||||||
|
|
||||||
|
Why this exists?:
|
||||||
|
One could use Bind to define ownership but then one would need to handle drive which
|
||||||
|
is unnecessary and produces code duplication.
|
||||||
|
|
||||||
|
It is also somewhat semantically wrong to include Owned Path into Bind
|
||||||
|
instead of user and group. Because owner and group in Bind are applied to
|
||||||
|
the original folder on the drive, not to the binding path. But maybe it is
|
||||||
|
ok since they are technically both owned. Idk yet.
|
||||||
|
"""
|
||||||
|
|
||||||
path: str
|
path: str
|
||||||
owner: str
|
owner: str
|
||||||
group: str
|
group: str
|
||||||
|
|
|
@ -411,11 +411,27 @@ class Service(ABC):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def owned_path(cls, path: str):
|
def owned_path(cls, path: str):
|
||||||
"""A default guess on folder ownership"""
|
"""Default folder ownership"""
|
||||||
|
service_name = cls.get_display_name()
|
||||||
|
|
||||||
|
try:
|
||||||
|
owner = cls.get_user()
|
||||||
|
if owner is None:
|
||||||
|
# TODO: assume root?
|
||||||
|
# (if we do not want to do assumptions, maybe not declare user optional?)
|
||||||
|
raise LookupError(f"no user for service: {service_name}")
|
||||||
|
group = cls.get_group()
|
||||||
|
if group is None:
|
||||||
|
raise LookupError(f"no group for service: {service_name}")
|
||||||
|
except Exception as error:
|
||||||
|
raise LookupError(
|
||||||
|
f"when deciding a bind for folder {path} of service {service_name}, error: {str(error)}"
|
||||||
|
)
|
||||||
|
|
||||||
return OwnedPath(
|
return OwnedPath(
|
||||||
path=path,
|
path=path,
|
||||||
owner=cls.get_user(),
|
owner=owner,
|
||||||
group=cls.get_group(),
|
group=group,
|
||||||
)
|
)
|
||||||
|
|
||||||
def pre_backup(self):
|
def pre_backup(self):
|
||||||
|
|
Loading…
Reference in a new issue