Upstream source code synchronization
This commit is contained in:
@@ -22,7 +22,7 @@ impl SyncEngine {
|
||||
let file_size = metadata.len();
|
||||
match self.api.create_upload_session(remote_dcim_uri, file_size, false, None, None, None).await {
|
||||
Ok(session) => {
|
||||
match crate::uploader::upload_file_chunked(&self.api, local_path, &session).await {
|
||||
match crate::uploader::upload_file_chunked(&self.api, local_path, &session, "album").await {
|
||||
Ok(_) => {
|
||||
let remote_uri = format!("{}/{}", remote_dcim_uri, file_name);
|
||||
let hash = crate::utils::quick_hash(local_path, file_size).await.unwrap_or_default();
|
||||
|
||||
@@ -78,6 +78,10 @@ impl SyncEngine {
|
||||
}
|
||||
}
|
||||
RemoteFileEvent::Deleted { uri, name } => {
|
||||
// 清理过期抑制条目
|
||||
let now = std::time::Instant::now();
|
||||
self.suppress_paths.retain(|_, ts| now.duration_since(*ts).as_secs() < 30);
|
||||
|
||||
let relative = crate::diff::remote_relative_path(
|
||||
remote_root,
|
||||
uri,
|
||||
@@ -86,6 +90,13 @@ impl SyncEngine {
|
||||
);
|
||||
tracing::info!("[远程事件] 删除: {}", relative);
|
||||
|
||||
// 被抑制的路径:上传失败清理远端碎片等场景,不应删除本地文件
|
||||
if self.suppress_paths.contains_key(&relative) {
|
||||
tracing::info!("[远程事件] 删除已抑制,跳过本地删除: {}", relative);
|
||||
self.suppress_paths.remove(&relative);
|
||||
return;
|
||||
}
|
||||
|
||||
let local_path = local_root.join(&relative);
|
||||
if local_path.exists() {
|
||||
if local_path.is_dir() {
|
||||
|
||||
Reference in New Issue
Block a user