fix
This commit is contained in:
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user