Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: upgrade collab version (#6038)
Nathan.fooo86be92ba1ba4
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lockindex 8c809e7d6f..2ce43d14f2 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock@@ -964,7 +964,7 @@ dependencies = [[[package]]name = "collab"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -989,14 +989,13 @@ dependencies = [[[package]]name = "collab-database"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-trait","chrono","collab","collab-entity",- "collab-plugins","dashmap 5.5.3","futures","getrandom 0.2.10",@@ -1019,7 +1018,7 @@ dependencies = [[[package]]name = "collab-document"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -1039,7 +1038,7 @@ dependencies = [[[package]]name = "collab-entity"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","bytes",@@ -1058,7 +1057,7 @@ dependencies = [[[package]]name = "collab-folder"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -1101,7 +1100,7 @@ dependencies = [[[package]]name = "collab-plugins"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-stream",@@ -1181,7 +1180,7 @@ dependencies = [[[package]]name = "collab-user"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","collab",diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.tomlindex 66a3b28567..c8488232b5 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml@@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]# To switch to the local path, run:# scripts/tool/update_collab_source.sh# ⚠️⚠️⚠️️-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }# Working directory: frontend# To update the commit ID, run:diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lockindex 6542daf3ae..cbf0e3167b 100644--- a/frontend/appflowy_web_app/src-tauri/Cargo.lock+++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock@@ -947,7 +947,7 @@ dependencies = [[[package]]name = "collab"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -972,14 +972,13 @@ dependencies = [[[package]]name = "collab-database"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-trait","chrono","collab","collab-entity",- "collab-plugins","dashmap 5.5.3","futures","getrandom 0.2.12",@@ -1002,7 +1001,7 @@ dependencies = [[[package]]name = "collab-document"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -1022,7 +1021,7 @@ dependencies = [[[package]]name = "collab-entity"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","bytes",@@ -1041,7 +1040,7 @@ dependencies = [[[package]]name = "collab-folder"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -1084,7 +1083,7 @@ dependencies = [[[package]]name = "collab-plugins"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-stream",@@ -1164,7 +1163,7 @@ dependencies = [[[package]]name = "collab-user"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","collab",diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.tomlindex 5dcbc5b76b..71a373a38a 100644--- a/frontend/appflowy_web_app/src-tauri/Cargo.toml+++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml@@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]# To switch to the local path, run:# scripts/tool/update_collab_source.sh# ⚠️⚠️⚠️️-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }# Working directory: frontend# To update the commit ID, run:diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex b323a2e3c8..48121e8896 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -825,7 +825,7 @@ dependencies = [[[package]]name = "collab"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -850,14 +850,13 @@ dependencies = [[[package]]name = "collab-database"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-trait","chrono","collab","collab-entity",- "collab-plugins","dashmap 5.5.3","futures","getrandom 0.2.10",@@ -880,7 +879,7 @@ dependencies = [[[package]]name = "collab-document"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -900,7 +899,7 @@ dependencies = [[[package]]name = "collab-entity"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","bytes",@@ -919,7 +918,7 @@ dependencies = [[[package]]name = "collab-folder"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","arc-swap",@@ -962,7 +961,7 @@ dependencies = [[[package]]name = "collab-plugins"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","async-stream",@@ -1042,7 +1041,7 @@ dependencies = [[[package]]name = "collab-user"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=520b75dbe84ff17a55cf9424a55028781ae0bfc6#520b75dbe84ff17a55cf9424a55028781ae0bfc6"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d"dependencies = ["anyhow","collab",diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.tomlindex b8ad17cc1c..f88d143116 100644--- a/frontend/rust-lib/Cargo.toml+++ b/frontend/rust-lib/Cargo.toml@@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120# To switch to the local path, run:# scripts/tool/update_collab_source.sh# ⚠️⚠️⚠️️-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "520b75dbe84ff17a55cf9424a55028781ae0bfc6" }+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" }# Working directory: frontend# To update the commit ID, run:diff --git a/frontend/rust-lib/collab-integrate/src/collab_builder.rs b/frontend/rust-lib/collab-integrate/src/collab_builder.rsindex 9800e1a130..da99addf0e 100644--- a/frontend/rust-lib/collab-integrate/src/collab_builder.rs+++ b/frontend/rust-lib/collab-integrate/src/collab_builder.rs@@ -250,7 +250,7 @@ impl AppFlowyCollabBuilder {let expected_collab_type = CollabType::WorkspaceDatabase;assert_eq!(object.collab_type, expected_collab_type);let collab = self.build_collab(&object, &collab_db, doc_state)?;- let workspace = WorkspaceDatabase::open(object.uid, collab, collab_db.clone(), collab_service);+ let workspace = WorkspaceDatabase::open(object.uid, collab, collab_service);self.flush_collab_if_not_exist(object.uid,@@ -399,7 +399,7 @@ impl KVDBCollabPersistenceImpl {}impl CollabPersistence for KVDBCollabPersistenceImpl {- fn load_collab(&self, collab: &mut Collab) {+ fn load_collab_from_disk(&self, collab: &mut Collab) {if let Some(collab_db) = self.db.upgrade() {let object_id = collab.object_id().to_string();let rocksdb_read = collab_db.read_txn();diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rsindex 6c204ce627..bd2e300f31 100644--- a/frontend/rust-lib/flowy-database2/src/manager.rs+++ b/frontend/rust-lib/flowy-database2/src/manager.rs@@ -13,7 +13,8 @@ use collab_database::error::DatabaseError;use collab_database::rows::RowId;use collab_database::views::DatabaseLayout;use collab_database::workspace_database::{- DatabaseCollabService, DatabaseMeta, EncodeCollabByOid, WorkspaceDatabase,+ DatabaseCollabPersistenceService, DatabaseCollabService, DatabaseMeta, EncodeCollabByOid,+ WorkspaceDatabase,};use collab_entity::{CollabType, EncodedCollab};use collab_plugins::local_storage::kv::KVTransactionDB;@@ -28,6 +29,7 @@ use flowy_database_pub::cloud::{DatabaseAIService, DatabaseCloudService, SummaryRowContent, TranslateItem, TranslateRowContent,};use flowy_error::{internal_error, FlowyError, FlowyResult};+use lib_dispatch::prelude::af_spawn;use lib_infra::box_any::BoxAny;use lib_infra::priority_task::TaskDispatcher;@@ -52,6 +54,7 @@ pub struct DatabaseManager {workspace_database: ArcSwapOption<RwLock<WorkspaceDatabase>>,task_scheduler: Arc<RwLock<TaskDispatcher>>,editors: Mutex<HashMap<String, Arc<DatabaseEditor>>>,+ removing_editor: Arc<Mutex<HashMap<String, Arc<DatabaseEditor>>>>,collab_builder: Arc<AppFlowyCollabBuilder>,cloud_service: Arc<dyn DatabaseCloudService>,ai_service: Arc<dyn DatabaseAIService>,@@ -70,6 +73,7 @@ impl DatabaseManager {workspace_database: Default::default(),task_scheduler,editors: Default::default(),+ removing_editor: Default::default(),collab_builder,cloud_service,ai_service,@@ -95,6 +99,7 @@ impl DatabaseManager {editor.close_all_views().await;}self.editors.lock().await.clear();+ self.removing_editor.lock().await.clear();// 3. Clear the workspace databaseif let Some(old_workspace_database) = self.workspace_database.swap(None) {let wdb = old_workspace_database.read().await;@@ -284,8 +289,17 @@ impl DatabaseManager {#[instrument(level = "trace", skip_all, err)]pub async fn open_database(&self, database_id: &str) -> FlowyResult<Arc<DatabaseEditor>> {- trace!("open database editor:{}", database_id);let lock = self.workspace_database()?;+ if let Some(database_editor) = self.removing_editor.lock().await.remove(database_id) {+ self+ .editors+ .lock()+ .await+ .insert(database_id.to_string(), database_editor.clone());+ return Ok(database_editor);+ }++ trace!("create database editor:{}", database_id);let database = lock.read().await@@ -339,8 +353,27 @@ impl DatabaseManager {if should_remove {trace!("remove database editor:{}", database_id);- editors.remove(&database_id);- workspace_database.close_database(&database_id);+ if let Some(editor) = editors.remove(&database_id) {+ self+ .removing_editor+ .lock()+ .await+ .insert(database_id.to_string(), editor);++ let weak_workspace_database = Arc::downgrade(&self.workspace_database()?);+ let weak_removing_editors = Arc::downgrade(&self.removing_editor);+ af_spawn(async move {+ tokio::time::sleep(std::time::Duration::from_secs(120)).await;+ if let Some(removing_editors) = weak_removing_editors.upgrade() {+ if removing_editors.lock().await.remove(&database_id).is_some() {+ if let Some(workspace_database) = weak_workspace_database.upgrade() {+ let wdb = workspace_database.write().await;+ wdb.close_database(&database_id);+ }+ }+ }+ });+ }}}@@ -700,7 +733,6 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl {uid: i64,object_id: &str,object_type: CollabType,- collab_db: Weak<CollabKVDB>,data_source: DataSource,) -> Result<Collab, DatabaseError> {let workspace_id = self@@ -710,9 +742,90 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl {let object = self.collab_builder.collab_object(&workspace_id, uid, object_id, object_type)?;+ let collab_db = self+ .user+ .collab_db(uid)+ .map_err(|err| DatabaseError::Internal(anyhow!("Failed to get collab db: {}", err)))?;let collab = self.collab_builder.build_collab(&object, &collab_db, data_source)?;Ok(collab)}++ fn persistence(&self) -> Option<Box<dyn DatabaseCollabPersistenceService>> {+ Some(Box::new(DatabasePersistenceImpl {+ user: self.user.clone(),+ }))+ }+}++pub struct DatabasePersistenceImpl {+ user: Arc<dyn DatabaseUser>,+}++impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {+ fn load_collab(&self, uid: i64, collab: &mut Collab) {+ if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {+ trace!("[Database]: load collab:{}", collab.object_id());+ let object_id = collab.object_id().to_string();+ let mut txn = collab.transact_mut();+ let db_read = collab_db.read_txn();+ let _ = db_read.load_doc_with_txn(uid, &object_id, &mut txn);+ }+ }++ fn delete_collab(&self, uid: i64, object_id: &str) -> Result<(), DatabaseError> {+ if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {+ let write_txn = collab_db.write_txn();+ write_txn.delete_doc(uid, object_id).unwrap();+ write_txn+ .commit_transaction()+ .map_err(|err| DatabaseError::Internal(anyhow!("failed to commit transaction: {}", err)))?;+ }+ Ok(())+ }++ fn is_collab_exist(&self, uid: i64, object_id: &str) -> bool {+ if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {+ let read_txn = collab_db.read_txn();+ return read_txn.is_exist(uid, object_id);+ }+ false+ }++ fn flush_collab(+ &self,+ uid: i64,+ object_id: &str,+ encode_collab: EncodedCollab,+ ) -> Result<(), DatabaseError> {+ trace!("[Database]: flush collab:{}", object_id);+ if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {+ let write_txn = collab_db.write_txn();+ write_txn+ .flush_doc(+ uid,+ object_id,+ encode_collab.state_vector.to_vec(),+ encode_collab.doc_state.to_vec(),+ )+ .map_err(|err| DatabaseError::Internal(anyhow!("failed to flush doc: {}", err)))?;++ write_txn+ .commit_transaction()+ .map_err(|err| DatabaseError::Internal(anyhow!("failed to commit transaction: {}", err)))?;+ }+ Ok(())+ }++ fn is_row_exist_partition(&self, uid: i64, row_ids: Vec<RowId>) -> (Vec<RowId>, Vec<RowId>) {+ if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {+ let read_txn = collab_db.read_txn();+ return row_ids+ .into_iter()+ .partition(|row_id| read_txn.is_exist(uid, row_id.as_ref()));+ }++ (vec![], row_ids)+ }}