Merge branch 'master' of github.com:Kozea/radicale
This commit is contained in:
		| @@ -533,7 +533,9 @@ class Application: | ||||
|         content_type = environ.get("CONTENT_TYPE") | ||||
|         if content_type: | ||||
|             tags = {value: key for key, value in storage.MIMETYPES.items()} | ||||
|             collection.set_meta("tag", tags[content_type.split(";")[0]]) | ||||
|             tag = tags.get(content_type.split(";")[0]) | ||||
|             if tag: | ||||
|                 collection.set_meta("tag", tag) | ||||
|         headers = {} | ||||
|         item_name = xmlutils.name_from_path(environ["PATH_INFO"], collection) | ||||
|         item = collection.get(item_name) | ||||
| @@ -546,14 +548,19 @@ class Application: | ||||
|             # Case 1: No item and no ETag precondition: Add new item | ||||
|             # Case 2: Item and ETag precondition verified: Modify item | ||||
|             # Case 3: Item and no Etag precondition: Force modifying item | ||||
|             items = list(vobject.readComponents(content)) | ||||
|             if items: | ||||
|             items = list(vobject.readComponents(content or "")) | ||||
|             if item: | ||||
|                 # PUT is modifying an existing item | ||||
|                 if items: | ||||
|                     new_item = collection.update(item_name, items[0]) | ||||
|                 else: | ||||
|                     new_item = None | ||||
|             elif item_name: | ||||
|                 # PUT is adding a new item | ||||
|                 if items: | ||||
|                     new_item = collection.upload(item_name, items[0]) | ||||
|                 else: | ||||
|                     new_item = None | ||||
|             else: | ||||
|                 # PUT is replacing the whole collection | ||||
|                 collection.delete() | ||||
|   | ||||
| @@ -578,7 +578,9 @@ class Collection(BaseCollection): | ||||
|                     except OSError: | ||||
|                         cls.logger.debug("Locking not supported") | ||||
|                 cls._lock_file_locked = True | ||||
|         try: | ||||
|             yield | ||||
|         finally: | ||||
|             with cls._lock: | ||||
|                 if mode == "r": | ||||
|                     cls._readers -= 1 | ||||
| @@ -592,7 +594,8 @@ class Collection(BaseCollection): | ||||
|                             cls.logger.debug("Unlocking not supported") | ||||
|                     elif os.name == "posix": | ||||
|                         try: | ||||
|                         fcntl.lockf(cls._lock_file.fileno(), fcntl.LOCK_UN) | ||||
|                             fcntl.lockf(cls._lock_file.fileno(), | ||||
|                                         fcntl.LOCK_UN) | ||||
|                         except OSError: | ||||
|                             cls.logger.debug("Unlocking not supported") | ||||
|                     cls._lock_file_locked = False | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Guillaume Ayoub
					Guillaume Ayoub