mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-10 18:40:53 +00:00
Replace collection in Collection.create_collection
This commit is contained in:
parent
9f2cbb81a3
commit
0675328a02
1 changed files with 9 additions and 0 deletions
|
@ -294,6 +294,10 @@ class BaseCollection:
|
|||
def create_collection(cls, href, collection=None, props=None):
|
||||
"""Create a collection.
|
||||
|
||||
If the collection already exists and neither ``collection`` nor
|
||||
``props`` are set, this method shouldn't do anything. Otherwise the
|
||||
existing collection must be replaced.
|
||||
|
||||
``collection`` is a list of vobject components.
|
||||
|
||||
``props`` are metadata values for the collection.
|
||||
|
@ -551,6 +555,11 @@ class Collection(BaseCollection):
|
|||
for card in collection:
|
||||
self.upload(self._find_available_file_name(), card)
|
||||
|
||||
# This operation is not atomic on the filesystem level but it's
|
||||
# very unlikely that one rename operations succeeds while the
|
||||
# other fails or that only one gets written to disk.
|
||||
if os.path.exists(filesystem_path):
|
||||
os.rename(filesystem_path, os.path.join(tmp_dir, "delete"))
|
||||
os.rename(tmp_filesystem_path, filesystem_path)
|
||||
sync_directory(parent_dir)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue