perf(sync): 流式处理冲突快照与解决载荷

This commit is contained in:
2026-09-09 06:16:21 +08:00
parent bd6ccc4237
commit 6373d8ee81
4 changed files with 149 additions and 22 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ use crate::{
use rusqlite::{params, OptionalExtension};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{fs, io::Write};
use std::io::Write;
use uuid::Uuid;
#[derive(Clone, Serialize, Deserialize)]
@@ -223,7 +223,7 @@ impl Workspace {
) -> Result<()> {
let path = self.resolve(local_path)?;
let digest = if path.is_file() {
self.sync_store_bytes(&fs::read(path)?)?
self.sync_store_file(&path)?
} else {
String::new()
};
@@ -363,7 +363,7 @@ impl Workspace {
let remote: Value = serde_json::from_str(&remote).map_err(|_| HostError::new("SYNC_RESPONSE_INVALID"))?;
let current_path=self.path_for_id(&file_id).unwrap_or_else(|_|local_path.clone());
let source=self.resolve(&current_path)?;
let current_hash=if source.is_file() {hash(&fs::read(source)?)} else {String::new()};
let current_hash=if source.is_file() {crate::payloads::hash_file(&source)?} else {String::new()};
Ok(serde_json::json!({"sequence":sequence,"file_id":file_id,"local_path":local_path,"local_hash":local_hash,"current_path":current_path,"current_hash":current_hash,"remote":remote}))
}).collect()
}