chore: bump up collab (#2740)

* chore: update collab version

* chore: log the error when open collab db

* chore: add log
This commit is contained in:
Nathan.fooo
2023-06-08 14:20:31 +08:00
committed by GitHub
parent 6e27d551d9
commit 37547a6485
9 changed files with 63 additions and 57 deletions

View File

@ -79,8 +79,7 @@ class RustKeyValue implements KeyValueStorage {
} }
@override @override
Future<void> clear() { Future<void> clear() async {
// TODO: implement clear // TODO(Lucas): implement clear
throw UnimplementedError();
} }
} }

View File

@ -693,10 +693,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: intl_utils name: intl_utils
sha256: db392393fbf891e3eb32f6beb1928b00cdb33e3c54597fd5f5dc5c43e5ba601c sha256: a509a2ada4d12c4dc70f9ca35c2fddf75f8b402409ac1a9e1b3dd8065681986b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.8.2" version: "2.8.3"
io: io:
dependency: transitive dependency: transitive
description: description:

View File

@ -99,7 +99,7 @@ checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]] [[package]]
name = "appflowy-integrate" name = "appflowy-integrate"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1024,7 +1024,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1042,7 +1042,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-client-ws" name = "collab-client-ws"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bytes", "bytes",
"collab-sync", "collab-sync",
@ -1060,7 +1060,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1086,7 +1086,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-derive" name = "collab-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1098,7 +1098,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1115,9 +1115,10 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono",
"collab", "collab",
"collab-derive", "collab-derive",
"collab-persistence", "collab-persistence",
@ -1134,7 +1135,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-persistence" name = "collab-persistence"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bincode", "bincode",
"chrono", "chrono",
@ -1154,7 +1155,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1185,7 +1186,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-sync" name = "collab-sync"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a647d9#a647d922ef432510d6be0abb5f968d9a75dc7011" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bytes", "bytes",
"collab", "collab",

View File

@ -34,12 +34,12 @@ default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"] custom-protocol = ["tauri/custom-protocol"]
[patch.crates-io] [patch.crates-io]
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
#collab = { path = "../../AppFlowy-Collab/collab" } #collab = { path = "../../AppFlowy-Collab/collab" }
#collab-folder = { path = "../../AppFlowy-Collab/collab-folder" } #collab-folder = { path = "../../AppFlowy-Collab/collab-folder" }

View File

@ -85,7 +85,7 @@ checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4"
[[package]] [[package]]
name = "appflowy-integrate" name = "appflowy-integrate"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -887,7 +887,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -905,7 +905,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-client-ws" name = "collab-client-ws"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bytes", "bytes",
"collab-sync", "collab-sync",
@ -923,7 +923,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -949,7 +949,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-derive" name = "collab-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -961,7 +961,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -978,9 +978,10 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono",
"collab", "collab",
"collab-derive", "collab-derive",
"collab-persistence", "collab-persistence",
@ -997,7 +998,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-persistence" name = "collab-persistence"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bincode", "bincode",
"chrono", "chrono",
@ -1017,7 +1018,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1048,7 +1049,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-sync" name = "collab-sync"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=046a91#046a916cc357f4b6c88f4f5a66a84ca0e14c3c62" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87f534#87f53452241a65275f5b2878ba57dff2a0e2b838"
dependencies = [ dependencies = [
"bytes", "bytes",
"collab", "collab",

View File

@ -33,11 +33,11 @@ opt-level = 3
incremental = false incremental = false
[patch.crates-io] [patch.crates-io]
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "046a91" } appflowy-integrate = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "87f534" }
#collab = { path = "../AppFlowy-Collab/collab" } #collab = { path = "../AppFlowy-Collab/collab" }
#collab-folder = { path = "../AppFlowy-Collab/collab-folder" } #collab-folder = { path = "../AppFlowy-Collab/collab-folder" }

View File

@ -199,6 +199,9 @@ pub enum ErrorCode {
#[error("Missing auth field")] #[error("Missing auth field")]
MissingAuthField = 65, MissingAuthField = 65,
#[error("Only one application can access the database")]
MultipleDBInstance = 66,
} }
impl ErrorCode { impl ErrorCode {

View File

@ -6,8 +6,8 @@ use appflowy_integrate::collab_builder::AppFlowyCollabBuilder;
use appflowy_integrate::CollabPersistenceConfig; use appflowy_integrate::CollabPersistenceConfig;
use collab::core::collab_state::CollabState; use collab::core::collab_state::CollabState;
use collab_folder::core::{ use collab_folder::core::{
Folder, FolderContext, TrashChange, TrashChangeReceiver, TrashInfo, TrashRecord, View, Folder, FolderContext, TrashChange, TrashChangeReceiver, TrashInfo, View, ViewChange,
ViewChange, ViewChangeReceiver, ViewLayout, Workspace, ViewChangeReceiver, ViewLayout, Workspace,
}; };
use parking_lot::Mutex; use parking_lot::Mutex;
use tokio_stream::wrappers::WatchStream; use tokio_stream::wrappers::WatchStream;
@ -15,7 +15,6 @@ use tokio_stream::StreamExt;
use tracing::{event, Level}; use tracing::{event, Level};
use flowy_error::{ErrorCode, FlowyError, FlowyResult}; use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use lib_infra::util::timestamp;
use crate::deps::{FolderCloudService, FolderUser}; use crate::deps::{FolderCloudService, FolderUser};
use crate::entities::{ use crate::entities::{
@ -114,7 +113,7 @@ impl Folder2Manager {
} }
/// Called immediately after the application launched fi the user already sign in/sign up. /// Called immediately after the application launched fi the user already sign in/sign up.
#[tracing::instrument(level = "debug", skip(self), err)] #[tracing::instrument(level = "info", skip(self), err)]
pub async fn initialize(&self, uid: i64, workspace_id: &str) -> FlowyResult<()> { pub async fn initialize(&self, uid: i64, workspace_id: &str) -> FlowyResult<()> {
let workspace_id = workspace_id.to_string(); let workspace_id = workspace_id.to_string();
if let Ok(collab_db) = self.user.collab_db() { if let Ok(collab_db) = self.user.collab_db() {
@ -176,6 +175,7 @@ impl Folder2Manager {
/// ///
pub async fn clear(&self, _user_id: i64) {} pub async fn clear(&self, _user_id: i64) {}
#[tracing::instrument(level = "info", skip_all, err)]
pub async fn create_workspace(&self, params: CreateWorkspaceParams) -> FlowyResult<Workspace> { pub async fn create_workspace(&self, params: CreateWorkspaceParams) -> FlowyResult<Workspace> {
let workspace = self let workspace = self
.cloud_service .cloud_service
@ -194,6 +194,7 @@ impl Folder2Manager {
Ok(workspace) Ok(workspace)
} }
#[tracing::instrument(level = "info", skip_all, err)]
pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<Workspace> { pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<Workspace> {
self.with_folder(Err(FlowyError::internal()), |folder| { self.with_folder(Err(FlowyError::internal()), |folder| {
let workspace = folder let workspace = folder
@ -281,7 +282,6 @@ impl Folder2Manager {
let folder = self.mutex_folder.lock(); let folder = self.mutex_folder.lock();
let folder = folder.as_ref().ok_or_else(folder_not_init_error)?; let folder = folder.as_ref().ok_or_else(folder_not_init_error)?;
let trash_ids = folder let trash_ids = folder
.trash
.get_all_trash() .get_all_trash()
.into_iter() .into_iter()
.map(|trash| trash.id) .map(|trash| trash.id)
@ -312,10 +312,7 @@ impl Folder2Manager {
#[tracing::instrument(level = "debug", skip(self), err)] #[tracing::instrument(level = "debug", skip(self), err)]
pub async fn move_view_to_trash(&self, view_id: &str) -> FlowyResult<()> { pub async fn move_view_to_trash(&self, view_id: &str) -> FlowyResult<()> {
self.with_folder((), |folder| { self.with_folder((), |folder| {
folder.trash.add_trash(vec![TrashRecord { folder.add_trash(vec![view_id.to_string()]);
id: view_id.to_string(),
created_at: timestamp(),
}]);
// notify the parent view that the view is moved to trash // notify the parent view that the view is moved to trash
send_notification(view_id, FolderNotification::DidMoveViewToTrash) send_notification(view_id, FolderNotification::DidMoveViewToTrash)
@ -463,13 +460,13 @@ impl Folder2Manager {
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub(crate) async fn get_all_trash(&self) -> Vec<TrashInfo> { pub(crate) async fn get_all_trash(&self) -> Vec<TrashInfo> {
self.with_folder(vec![], |folder| folder.trash.get_all_trash()) self.with_folder(vec![], |folder| folder.get_all_trash())
} }
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub(crate) async fn restore_all_trash(&self) { pub(crate) async fn restore_all_trash(&self) {
self.with_folder((), |folder| { self.with_folder((), |folder| {
folder.trash.clear(); folder.remote_all_trash();
}); });
send_notification("trash", FolderNotification::DidUpdateTrash) send_notification("trash", FolderNotification::DidUpdateTrash)
@ -480,14 +477,14 @@ impl Folder2Manager {
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub(crate) async fn restore_trash(&self, trash_id: &str) { pub(crate) async fn restore_trash(&self, trash_id: &str) {
self.with_folder((), |folder| { self.with_folder((), |folder| {
folder.trash.delete_trash(vec![trash_id]); folder.delete_trash(vec![trash_id.to_string()]);
}); });
} }
/// Delete all the trash permanently. /// Delete all the trash permanently.
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self))]
pub(crate) async fn delete_all_trash(&self) { pub(crate) async fn delete_all_trash(&self) {
let deleted_trash = self.with_folder(vec![], |folder| folder.trash.get_all_trash()); let deleted_trash = self.with_folder(vec![], |folder| folder.get_all_trash());
for trash in deleted_trash { for trash in deleted_trash {
let _ = self.delete_trash(&trash.id).await; let _ = self.delete_trash(&trash.id).await;
} }
@ -503,7 +500,7 @@ impl Folder2Manager {
pub async fn delete_trash(&self, view_id: &str) -> FlowyResult<()> { pub async fn delete_trash(&self, view_id: &str) -> FlowyResult<()> {
let view = self.with_folder(None, |folder| folder.views.get_view(view_id)); let view = self.with_folder(None, |folder| folder.views.get_view(view_id));
self.with_folder((), |folder| { self.with_folder((), |folder| {
folder.trash.delete_trash(vec![view_id]); folder.delete_trash(vec![view_id.to_string()]);
folder.views.delete_views(vec![view_id]); folder.views.delete_views(vec![view_id]);
}); });
if let Some(view) = view { if let Some(view) = view {
@ -667,7 +664,7 @@ fn listen_on_trash_change(mut rx: TrashChangeReceiver, weak_mutex_folder: &Weak<
unique_ids.insert(view.parent_view_id); unique_ids.insert(view.parent_view_id);
} }
let repeated_trash: RepeatedTrashPB = folder.trash.get_all_trash().into(); let repeated_trash: RepeatedTrashPB = folder.get_all_trash().into();
send_notification("trash", FolderNotification::DidUpdateTrash) send_notification("trash", FolderNotification::DidUpdateTrash)
.payload(repeated_trash) .payload(repeated_trash)
.send(); .send();
@ -683,7 +680,6 @@ fn listen_on_trash_change(mut rx: TrashChangeReceiver, weak_mutex_folder: &Weak<
/// Return the views that belong to the workspace. The views are filtered by the trash. /// Return the views that belong to the workspace. The views are filtered by the trash.
fn get_workspace_view_pbs(workspace_id: &str, folder: &Folder) -> Vec<ViewPB> { fn get_workspace_view_pbs(workspace_id: &str, folder: &Folder) -> Vec<ViewPB> {
let trash_ids = folder let trash_ids = folder
.trash
.get_all_trash() .get_all_trash()
.into_iter() .into_iter()
.map(|trash| trash.id) .map(|trash| trash.id)
@ -724,7 +720,6 @@ fn notify_parent_view_did_change<T: AsRef<str>>(
let folder = folder.as_ref()?; let folder = folder.as_ref()?;
let workspace_id = folder.get_current_workspace_id()?; let workspace_id = folder.get_current_workspace_id()?;
let trash_ids = folder let trash_ids = folder
.trash
.get_all_trash() .get_all_trash()
.into_iter() .into_iter()
.map(|trash| trash.id) .map(|trash| trash.id)

View File

@ -5,7 +5,7 @@ use appflowy_integrate::RocksCollabDB;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use parking_lot::RwLock; use parking_lot::RwLock;
use flowy_error::FlowyError; use flowy_error::{ErrorCode, FlowyError};
use flowy_sqlite::ConnectionPool; use flowy_sqlite::ConnectionPool;
use flowy_sqlite::{schema::user_table, DBConnection, Database}; use flowy_sqlite::{schema::user_table, DBConnection, Database};
@ -41,8 +41,8 @@ impl UserDB {
tracing::trace!("open user db {} at path: {}", user_id, dir); tracing::trace!("open user db {} at path: {}", user_id, dir);
let db = flowy_sqlite::init(&dir).map_err(|e| { let db = flowy_sqlite::init(&dir).map_err(|e| {
tracing::error!("open user: {} db failed, {:?}", user_id, e); tracing::error!("open user db failed, {:?}", e);
FlowyError::internal().context(e) FlowyError::new(ErrorCode::MultipleDBInstance, e)
})?; })?;
let pool = db.get_pool(); let pool = db.get_pool();
write_guard.insert(user_id.to_owned(), db); write_guard.insert(user_id.to_owned(), db);
@ -68,7 +68,14 @@ impl UserDB {
dir.push("collab_db"); dir.push("collab_db");
tracing::trace!("open collab db {} at path: {:?}", user_id, dir); tracing::trace!("open collab db {} at path: {:?}", user_id, dir);
let db = RocksCollabDB::open(dir).map_err(|err| FlowyError::internal().context(err))?; let db = match RocksCollabDB::open(dir) {
Ok(db) => Ok(db),
Err(err) => {
tracing::error!("open collab db failed, {:?}", err);
Err(FlowyError::new(ErrorCode::MultipleDBInstance, err))
},
}?;
let db = Arc::new(db); let db = Arc::new(db);
write_guard.insert(user_id.to_owned(), db.clone()); write_guard.insert(user_id.to_owned(), db.clone());
drop(write_guard); drop(write_guard);