fix(webdav): partial fix: remove dead props on del

ensure that dead properties are correctly deleted on resource deletion

    **IMPORTANT**: this is a partial fix:
    dead properties are not deleted if resource is deleted from API !
    code need to be reviewed to attach property directly to resource + use on delete cascade
This commit is contained in:
Edouard Vanbelle
2026-06-30 20:45:08 +02:00
parent 21ac3a178f
commit d52c1a2397
2 changed files with 25 additions and 3 deletions
@@ -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())
+8 -3
View File
@@ -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 ───────────────────────────