diff --git a/src/interfaces/api/handlers/webdav_handler.rs b/src/interfaces/api/handlers/webdav_handler.rs index 0357c39e..6f223477 100644 --- a/src/interfaces/api/handlers/webdav_handler.rs +++ b/src/interfaces/api/handlers/webdav_handler.rs @@ -1587,6 +1587,23 @@ async fn handle_delete( None => return Err(AppError::not_found(format!("Resource not found: {}", path))), } + // Reap dead properties so a future resource at the same path + // doesn't inherit tombstone metadata from the deleted one. Best- + // effort: a failure to clear leaves orphan rows but the user- + // facing DELETE has succeeded, so we don't propagate the error. + // Caught by tests/api/webdav_dead_properties.hurl Step 10. + if let Err(e) = state + .webdav_dead_props + .remove_resource(&path, user.id) + .await + { + tracing::warn!( + user_id = %user.id, + path = %path, + "dead-property cleanup on DELETE failed: {e}" + ); + } + Ok(Response::builder() .status(StatusCode::NO_CONTENT) .body(Body::empty()) diff --git a/tests/webdav/test_thumbnail_update.sh b/tests/webdav/test_thumbnail_update.sh index 284f91bc..12333999 100755 --- a/tests/webdav/test_thumbnail_update.sh +++ b/tests/webdav/test_thumbnail_update.sh @@ -143,13 +143,18 @@ else fi # ── Step 1: PUT dedup-test.jpg ─────────────────────────────── -# /webdav always returns 204 (update_file_streaming handles create+update) +# Post commit 43cf4a2b, /webdav distinguishes create (201) from +# overwrite (204) per RFC 7231 §4.3.4. The cleanup loop above +# (regular-listing + trash purge) guarantees this is a fresh +# resource, so we expect 201. Step 2 below tests the overwrite +# case (expects 204) — the 201/204 split itself is the regression +# guard. echo " step 1: PUT $REMOTE..." STATUS=$(webdav_put "$REMOTE" "$FIXTURE_V1" "image/jpeg") echo " step 1: WebDAV PUT → $STATUS" -[[ "$STATUS" == "204" ]] || fail "WebDAV PUT expected 204, got $STATUS" -pass "WebDAV PUT dedup-test.jpg → 204" +[[ "$STATUS" == "201" ]] || fail "WebDAV PUT expected 201, got $STATUS" +pass "WebDAV PUT dedup-test.jpg → 201" # ── find file_id from REST listing ───────────────────────────