No need to merge if the contents are equal

This commit is contained in:
Andras Schmelczer 2025-01-03 18:25:00 +00:00
commit b074202ed8
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -61,15 +61,7 @@ pub async fn create_document(
.context("Failed to decode base64 content in request") .context("Failed to decode base64 content in request")
.map_err(client_error)?; .map_err(client_error)?;
let merged_content = merge( if content_bytes == existing_version.content {
&[], // the empty string is the first common parent of the two documents,
&existing_version.content,
&content_bytes,
)
.context("Failed to decode bytes as UTF-8")
.map_err(client_error)?;
if merged_content == existing_version.content {
info!( info!(
"Content of the new version is the same as the existing version. Not creating a \ "Content of the new version is the same as the existing version. Not creating a \
new version." new version."
@ -82,6 +74,14 @@ pub async fn create_document(
return Ok(Json(existing_version.into())); return Ok(Json(existing_version.into()));
} }
let merged_content = merge(
&[], // the empty string is the first common parent of the two documents,
&existing_version.content,
&content_bytes,
)
.context("Failed to decode bytes as UTF-8")
.map_err(client_error)?;
StoredDocumentVersion { StoredDocumentVersion {
vault_id, vault_id,
vault_update_id: last_update_id + 1, vault_update_id: last_update_id + 1,