From ce9be10cdbc2ee563bb8b7de4c241dea1dba30a4 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Tue, 4 Apr 2023 15:12:09 +0800 Subject: [PATCH] fix core --- core/src/location/file_path_helper.rs | 58 ++++++++++++++------------- core/src/sync/manager.rs | 2 +- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/core/src/location/file_path_helper.rs b/core/src/location/file_path_helper.rs index a7a766c20..ea0f3a4d3 100644 --- a/core/src/location/file_path_helper.rs +++ b/core/src/location/file_path_helper.rs @@ -308,7 +308,7 @@ impl LastFilePathIdManager { #[cfg(feature = "location-watcher")] pub async fn create_file_path( &self, - library @ Library { db, sync, .. }: &Library, + Library { db, sync, .. }: &Library, MaterializedPath { materialized_path, is_dir, @@ -342,41 +342,43 @@ impl LastFilePathIdManager { let next_id = *last_id_ref + 1; - let created_path = library - .sync + let params = [ + ("materialized_path", json!(materialized_path)), + ("name", json!(name)), + ("extension", json!(extension)), + ("inode", json!(inode.to_le_bytes())), + ("device", json!(device.to_le_bytes())), + ("is_dir", json!(is_dir)), + ] + .into_iter() + .map(Some) + .chain([parent_id.map(|parent_id| { + ( + "parent_id", + json!(sync::file_path::SyncId { + location: sync::location::SyncId { + pub_id: location.pub_id.clone() + }, + id: parent_id + }), + ) + })]) + .flatten() + .collect::>(); + + let created_path = sync .write_op( - &library.db, - library.sync.unique_shared_create( + &db, + sync.unique_shared_create( sync::file_path::SyncId { location: sync::location::SyncId { pub_id: location.pub_id.clone(), }, id: next_id, }, - [ - ("materialized_path", json!(materialized_path)), - ("name", json!(name)), - ("extension", json!(extension)), - ("inode", json!(inode.to_le_bytes())), - ("device", json!(device.to_le_bytes())), - ("is_dir", json!(is_dir)), - ] - .into_iter() - .map(Some) - .chain([parent_id.map(|parent_id| { - ( - "parent_id", - json!(sync::file_path::SyncId { - location: sync::location::SyncId { - pub_id: location.pub_id.clone() - }, - id: parent_id - }), - ) - })]) - .flatten(), + params, ), - library.db.file_path().create( + db.file_path().create( next_id, location::id::equals(location_id), materialized_path.into_owned(), diff --git a/core/src/sync/manager.rs b/core/src/sync/manager.rs index 483301271..cfbde2963 100644 --- a/core/src/sync/manager.rs +++ b/core/src/sync/manager.rs @@ -460,7 +460,7 @@ impl SyncManager { >( &self, id: TSyncId, - values: impl IntoIterator, + values: impl IntoIterator + 'static, ) -> CRDTOperation { self.new_op(CRDTOperationType::Shared(SharedOperation { model: TModel::MODEL.to_string(),