Clean the user's collection creation code
This commit is contained in:
parent
04010ff8d3
commit
d322d3f394
@ -305,18 +305,13 @@ class Application:
|
|||||||
# Create principal collection
|
# Create principal collection
|
||||||
if user and is_authenticated:
|
if user and is_authenticated:
|
||||||
principal_path = "/%s/" % user
|
principal_path = "/%s/" % user
|
||||||
if self.authorized(user, self.Collection(principal_path, True),
|
collection = self.Collection(principal_path, True)
|
||||||
"w"):
|
if self.authorized(user, collection, "w"):
|
||||||
with self.Collection.acquire_lock("r"):
|
with self.Collection.acquire_lock("r"):
|
||||||
principal = next(self.Collection.discover(principal_path),
|
principal = next(
|
||||||
None)
|
self.Collection.discover(principal_path), None)
|
||||||
if not principal or principal.path != principal_path.strip("/"):
|
if not principal or principal.path != user:
|
||||||
with self.Collection.acquire_lock("w"):
|
with self.Collection.acquire_lock("w"):
|
||||||
# the collection might exist by now
|
|
||||||
principal = next(self.Collection.discover(
|
|
||||||
principal_path), None)
|
|
||||||
if (not principal or
|
|
||||||
principal.path != principal_path.strip("/")):
|
|
||||||
self.Collection.create_collection(principal_path)
|
self.Collection.create_collection(principal_path)
|
||||||
|
|
||||||
# Get content
|
# Get content
|
||||||
|
@ -407,11 +407,14 @@ class Collection(BaseCollection):
|
|||||||
folder = os.path.expanduser(
|
folder = os.path.expanduser(
|
||||||
cls.configuration.get("storage", "filesystem_folder"))
|
cls.configuration.get("storage", "filesystem_folder"))
|
||||||
path = path_to_filesystem(folder, href)
|
path = path_to_filesystem(folder, href)
|
||||||
if not os.path.exists(path):
|
|
||||||
|
self = cls(href)
|
||||||
|
if os.path.exists(path):
|
||||||
|
return self
|
||||||
|
else:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if not tag and collection:
|
if not tag and collection:
|
||||||
tag = collection[0].name
|
tag = collection[0].name
|
||||||
self = cls(href)
|
|
||||||
|
|
||||||
if tag == "VCALENDAR":
|
if tag == "VCALENDAR":
|
||||||
self.set_meta("tag", "VCALENDAR")
|
self.set_meta("tag", "VCALENDAR")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user