diff --git a/backend/sync_server/src/server/create_document.rs b/backend/sync_server/src/server/create_document.rs index 50b9d862..fc55b022 100644 --- a/backend/sync_server/src/server/create_document.rs +++ b/backend/sync_server/src/server/create_document.rs @@ -61,15 +61,7 @@ pub async fn create_document( .context("Failed to decode base64 content in request") .map_err(client_error)?; - 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)?; - - if merged_content == existing_version.content { + if content_bytes == existing_version.content { info!( "Content of the new version is the same as the existing version. Not creating a \ new version." @@ -82,6 +74,14 @@ pub async fn create_document( 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 { vault_id, vault_update_id: last_update_id + 1,