Skip to content

Commit

Permalink
Merge pull request #1664 from pbiering/issue-1133
Browse files Browse the repository at this point in the history
Fix for Issue 1133
  • Loading branch information
pbiering authored Dec 25, 2024
2 parents 6569e48 + 1e8d9ed commit a4266c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Improve: disable fsync during storage verification
* Improve: suppress duplicate log lines on startup
* Contrib: logwatch config and script
* Improve: log precondition result on PUT request

## 3.3.2
* Fix: debug logging in rights/from_file
Expand Down
7 changes: 7 additions & 0 deletions radicale/app/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,22 @@ def do_PUT(self, environ: types.WSGIEnviron, base_prefix: str,
etag = environ.get("HTTP_IF_MATCH", "")
if not item and etag:
# Etag asked but no item found: item has been removed
logger.warning("Precondition failed on PUT request for %r (HTTP_IF_MATCH: %s, item not existing)", path, etag)
return httputils.PRECONDITION_FAILED
if item and etag and item.etag != etag:
# Etag asked but item not matching: item has changed
logger.warning("Precondition failed on PUT request for %r (HTTP_IF_MATCH: %s, item has different etag: %s)", path, etag, item.etag)
return httputils.PRECONDITION_FAILED
if item and etag:
logger.debug("Precondition passed on PUT request for %r (HTTP_IF_MATCH: %s, item has etag: %s)", path, etag, item.etag)

match = environ.get("HTTP_IF_NONE_MATCH", "") == "*"
if item and match:
# Creation asked but item found: item can't be replaced
logger.warning("Precondition failed on PUT request for %r (HTTP_IF_NONE_MATCH: *, creation requested but item found with etag: %s)", path, item.etag)
return httputils.PRECONDITION_FAILED
if match:
logger.debug("Precondition passed on PUT request for %r (HTTP_IF_NONE_MATCH: *)", path)

if (tag != prepared_tag or
prepared_write_whole_collection != write_whole_collection):
Expand Down

0 comments on commit a4266c9

Please sign in to comment.