chore: upgrade collab verison (#6047)

This commit is contained in:
Nathan.fooo 2024-08-23 15:40:48 +08:00 committed by GitHub
parent a206d9aa8c
commit 8ae67c5098
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 108 additions and 71 deletions

View File

@ -964,7 +964,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -989,7 +989,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1018,7 +1018,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1038,7 +1038,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1057,7 +1057,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1100,7 +1100,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1180,7 +1180,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",

View File

@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -947,7 +947,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -972,7 +972,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1001,7 +1001,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1021,7 +1021,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1040,7 +1040,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1083,7 +1083,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1163,7 +1163,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",

View File

@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -825,7 +825,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -850,7 +850,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -879,7 +879,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -899,7 +899,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -918,7 +918,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -961,7 +961,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1041,7 +1041,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=79e649061da9245d81b9114f3aaaf0064c265c97#79e649061da9245d81b9114f3aaaf0064c265c97"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",

View File

@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "79e649061da9245d81b9114f3aaaf0064c265c97" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -8,7 +8,9 @@ use arc_swap::{ArcSwap, ArcSwapOption};
use collab::core::collab::DataSource; use collab::core::collab::DataSource;
use collab::core::collab_plugin::CollabPersistence; use collab::core::collab_plugin::CollabPersistence;
use collab::preclude::{Collab, CollabBuilder}; use collab::preclude::{Collab, CollabBuilder};
use collab_database::workspace_database::{DatabaseCollabService, WorkspaceDatabase}; use collab_database::workspace_database::{
DatabaseCollabCloudService, DatabaseCollabService, WorkspaceDatabase,
};
use collab_document::blocks::DocumentData; use collab_document::blocks::DocumentData;
use collab_document::document::Document; use collab_document::document::Document;
use collab_entity::{CollabObject, CollabType}; use collab_entity::{CollabObject, CollabType};
@ -236,10 +238,7 @@ impl AppFlowyCollabBuilder {
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[instrument( #[instrument(level = "trace", skip_all)]
level = "trace",
skip(self, object, doc_state, collab_db, builder_config, collab_service)
)]
pub fn create_workspace_database( pub fn create_workspace_database(
&self, &self,
object: CollabObject, object: CollabObject,
@ -247,11 +246,12 @@ impl AppFlowyCollabBuilder {
collab_db: Weak<CollabKVDB>, collab_db: Weak<CollabKVDB>,
builder_config: CollabBuilderConfig, builder_config: CollabBuilderConfig,
collab_service: impl DatabaseCollabService, collab_service: impl DatabaseCollabService,
cloud_service: impl DatabaseCollabCloudService,
) -> Result<Arc<RwLock<WorkspaceDatabase>>, Error> { ) -> Result<Arc<RwLock<WorkspaceDatabase>>, Error> {
let expected_collab_type = CollabType::WorkspaceDatabase; let expected_collab_type = CollabType::WorkspaceDatabase;
assert_eq!(object.collab_type, expected_collab_type); assert_eq!(object.collab_type, expected_collab_type);
let collab = self.build_collab(&object, &collab_db, doc_state)?; let collab = self.build_collab(&object, &collab_db, doc_state)?;
let workspace = WorkspaceDatabase::open(object.uid, collab, collab_service); let workspace = WorkspaceDatabase::open(collab, collab_service, cloud_service);
self.flush_collab_if_not_exist( self.flush_collab_if_not_exist(
object.uid, object.uid,

View File

@ -13,8 +13,8 @@ use collab_database::error::DatabaseError;
use collab_database::rows::RowId; use collab_database::rows::RowId;
use collab_database::views::DatabaseLayout; use collab_database::views::DatabaseLayout;
use collab_database::workspace_database::{ use collab_database::workspace_database::{
DatabaseCollabPersistenceService, DatabaseCollabService, DatabaseMeta, EncodeCollabByOid, DatabaseCollabCloudService, DatabaseCollabPersistenceService, DatabaseCollabService,
WorkspaceDatabase, DatabaseMeta, EncodeCollabByOid, WorkspaceDatabase,
}; };
use collab_entity::{CollabType, EncodedCollab}; use collab_entity::{CollabType, EncodedCollab};
use collab_plugins::local_storage::kv::KVTransactionDB; use collab_plugins::local_storage::kv::KVTransactionDB;
@ -107,9 +107,12 @@ impl DatabaseManager {
} }
let collab_db = self.user.collab_db(uid)?; let collab_db = self.user.collab_db(uid)?;
let collab_builder = UserDatabaseCollabServiceImpl { let collab_service = WorkspaceDatabaseCollabServiceImpl {
user: self.user.clone(), user: self.user.clone(),
collab_builder: self.collab_builder.clone(), collab_builder: self.collab_builder.clone(),
};
let collab_cloud_service = WorkspaceDatabaseCloudServiceImpl {
user: self.user.clone(),
cloud_service: self.cloud_service.clone(), cloud_service: self.cloud_service.clone(),
}; };
@ -167,7 +170,8 @@ impl DatabaseManager {
workspace_database_data_source, workspace_database_data_source,
collab_db, collab_db,
CollabBuilderConfig::default().sync_enable(true), CollabBuilderConfig::default().sync_enable(true),
collab_builder, collab_service,
collab_cloud_service,
)?; )?;
self.workspace_database.store(Some(workspace_database)); self.workspace_database.store(Some(workspace_database));
Ok(()) Ok(())
@ -673,14 +677,13 @@ impl DatabaseManager {
} }
} }
struct UserDatabaseCollabServiceImpl { struct WorkspaceDatabaseCloudServiceImpl {
user: Arc<dyn DatabaseUser>, user: Arc<dyn DatabaseUser>,
collab_builder: Arc<AppFlowyCollabBuilder>,
cloud_service: Arc<dyn DatabaseCloudService>, cloud_service: Arc<dyn DatabaseCloudService>,
} }
#[async_trait] #[async_trait]
impl DatabaseCollabService for UserDatabaseCollabServiceImpl { impl DatabaseCollabCloudService for WorkspaceDatabaseCloudServiceImpl {
async fn get_encode_collab( async fn get_encode_collab(
&self, &self,
object_id: &str, object_id: &str,
@ -726,16 +729,27 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl {
}, },
} }
} }
}
struct WorkspaceDatabaseCollabServiceImpl {
user: Arc<dyn DatabaseUser>,
collab_builder: Arc<AppFlowyCollabBuilder>,
}
#[async_trait]
impl DatabaseCollabService for WorkspaceDatabaseCollabServiceImpl {
///NOTE: this method doesn't initialize plugins, however it is passed into WorkspaceDatabase, ///NOTE: this method doesn't initialize plugins, however it is passed into WorkspaceDatabase,
/// therefore all Database/DatabaseRow creation methods must initialize plugins thmselves. /// therefore all Database/DatabaseRow creation methods must initialize plugins thmselves.
fn build_collab( fn build_collab(
&self, &self,
uid: i64,
object_id: &str, object_id: &str,
object_type: CollabType, object_type: CollabType,
data_source: DataSource, data_source: DataSource,
) -> Result<Collab, DatabaseError> { ) -> Result<Collab, DatabaseError> {
let uid = self
.user
.user_id()
.map_err(|err| DatabaseError::Internal(err.into()))?;
let workspace_id = self let workspace_id = self
.user .user
.workspace_id() .workspace_id()
@ -765,8 +779,13 @@ pub struct DatabasePersistenceImpl {
} }
impl DatabaseCollabPersistenceService for DatabasePersistenceImpl { impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {
fn load_collab(&self, uid: i64, collab: &mut Collab) { fn load_collab(&self, collab: &mut Collab) {
if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { let result = self
.user
.user_id()
.map(|uid| (uid, self.user.collab_db(uid).map(|weak| weak.upgrade())));
if let Ok((uid, Ok(Some(collab_db)))) = result {
let object_id = collab.object_id().to_string(); let object_id = collab.object_id().to_string();
let db_read = collab_db.read_txn(); let db_read = collab_db.read_txn();
if !db_read.is_exist(uid, &object_id) { if !db_read.is_exist(uid, &object_id) {
@ -795,7 +814,11 @@ impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {
} }
} }
fn delete_collab(&self, uid: i64, object_id: &str) -> Result<(), DatabaseError> { fn delete_collab(&self, object_id: &str) -> Result<(), DatabaseError> {
let uid = self
.user
.user_id()
.map_err(|err| DatabaseError::Internal(err.into()))?;
if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {
let write_txn = collab_db.write_txn(); let write_txn = collab_db.write_txn();
write_txn.delete_doc(uid, object_id).unwrap(); write_txn.delete_doc(uid, object_id).unwrap();
@ -806,21 +829,33 @@ impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {
Ok(()) Ok(())
} }
fn is_collab_exist(&self, uid: i64, object_id: &str) -> bool { fn is_collab_exist(&self, object_id: &str) -> bool {
match self
.user
.user_id()
.map_err(|err| DatabaseError::Internal(err.into()))
{
Ok(uid) => {
if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {
let read_txn = collab_db.read_txn(); let read_txn = collab_db.read_txn();
return read_txn.is_exist(uid, object_id); return read_txn.is_exist(uid, object_id);
} }
false false
},
Err(_) => false,
}
} }
fn flush_collab( fn flush_collab(
&self, &self,
uid: i64,
object_id: &str, object_id: &str,
encode_collab: EncodedCollab, encode_collab: EncodedCollab,
) -> Result<(), DatabaseError> { ) -> Result<(), DatabaseError> {
trace!("[Database]: flush collab:{}", object_id); trace!("[Database]: flush collab:{}", object_id);
let uid = self
.user
.user_id()
.map_err(|err| DatabaseError::Internal(err.into()))?;
if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {
let write_txn = collab_db.write_txn(); let write_txn = collab_db.write_txn();
write_txn write_txn
@ -839,13 +874,15 @@ impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {
Ok(()) Ok(())
} }
fn is_row_exist_partition(&self, uid: i64, row_ids: Vec<RowId>) -> (Vec<RowId>, Vec<RowId>) { fn is_row_exist_partition(&self, row_ids: Vec<RowId>) -> (Vec<RowId>, Vec<RowId>) {
if let Ok(uid) = self.user.user_id() {
if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) {
let read_txn = collab_db.read_txn(); let read_txn = collab_db.read_txn();
return row_ids return row_ids
.into_iter() .into_iter()
.partition(|row_id| read_txn.is_exist(uid, row_id.as_ref())); .partition(|row_id| read_txn.is_exist(uid, row_id.as_ref()));
} }
}
(vec![], row_ids) (vec![], row_ids)
} }