sharing: cosmetics, check existence of collection before create

This commit is contained in:
Peter Bieringer
2026-03-05 21:31:32 +01:00
parent bef0727b94
commit 6070fe67da
3 changed files with 37 additions and 14 deletions

View File

@@ -685,6 +685,14 @@ class BaseSharing:
logger.error(api_info + ": missing PathMapped")
return httputils.bad_request("Missing PathMapped")
## check whether collection exists
with self._storage.acquire_lock("r", user, path=PathMapped):
item = next(iter(self._storage.discover(PathMapped)), None)
if not item:
return httputils.NOT_FOUND
if not isinstance(item, storage.BaseCollection):
return httputils.METHOD_NOT_ALLOWED
if Permissions is None:
if ShareType == "token":
Permissions = self.default_permissions_create_token
@@ -733,6 +741,7 @@ class BaseSharing:
else:
User = user
# v1: create uuid token with 2x 32 bytes = 256 bit
token = "v1/" + str(base64.urlsafe_b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes), 'utf-8')