This commit is contained in:
2025-11-11 13:27:07 +01:00
parent 8751637b92
commit 7f371b2ab6
10 changed files with 672 additions and 185 deletions
+24 -4
View File
@@ -1420,12 +1420,32 @@ impl<'a> DocumentsService<'a> {
checksum = %checksum_hex,
"upload rejected because document already exists",
);
let mut message = String::from("a document with the same contents already exists");
let mut details = json!({
"conflict_document_id": document.id,
});
if let Some(deleted_at) = document.deleted_at {
message.push_str(
". Note: the existing document is currently in the trash.",
);
if let Some(obj) = details.as_object_mut() {
obj.insert(
"conflict_document_in_trash".to_string(),
Value::Bool(true),
);
obj.insert(
"conflict_document_deleted_at".to_string(),
Value::String(to_iso(deleted_at)),
);
}
}
return Err(
AppError::conflict("a document with the same contents already exists")
AppError::conflict(message)
.with_code("duplicate_document")
.with_details(json!({
"conflict_document_id": document.id,
})),
.with_details(details),
);
}