fix: workspace id not match (#5454)

This commit is contained in:
Nathan.fooo 2024-06-03 16:34:54 +08:00 committed by GitHub
parent 4762d69851
commit 9c9168ac5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View File

@ -56,6 +56,8 @@ pub(crate) async fn open_document_handler(
let manager = upgrade_document(manager)?;
let params: OpenDocumentParams = data.into_inner().try_into()?;
let doc_id = params.document_id;
manager.open_document(&doc_id).await?;
let document = manager.get_document(&doc_id).await?;
let document_data = document.lock().get_document_data()?;
data_result_ok(DocumentDataPB::from(document_data))

View File

@ -77,7 +77,9 @@ impl DocumentManager {
}
pub async fn initialize(&self, _uid: i64) -> FlowyResult<()> {
trace!("initialize document manager");
self.documents.clear();
self.removing_documents.clear();
Ok(())
}
@ -130,9 +132,6 @@ impl DocumentManager {
}
}
/// Returns Document for given object id
/// If the document does not exist in local disk, try get the doc state from the cloud.
/// If the document exists, open the document and cache it
#[tracing::instrument(level = "info", skip(self), err)]
pub async fn get_document(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> {
if let Some(doc) = self.documents.get(doc_id).map(|item| item.value().clone()) {
@ -142,6 +141,17 @@ impl DocumentManager {
if let Some(doc) = self.restore_document_from_removing(doc_id) {
return Ok(doc);
}
return Err(FlowyError::internal().with_context("Call open document first"));
}
/// Returns Document for given object id
/// If the document does not exist in local disk, try get the doc state from the cloud.
/// If the document exists, open the document and cache it
#[tracing::instrument(level = "info", skip(self), err)]
async fn create_document_instance(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> {
if let Some(doc) = self.documents.get(doc_id).map(|item| item.value().clone()) {
return Ok(doc);
}
let mut doc_state = DataSource::Disk;
// If the document does not exist in local disk, try get the doc state from the cloud. This happens
@ -164,7 +174,12 @@ impl DocumentManager {
}
let uid = self.user_service.user_id()?;
event!(tracing::Level::DEBUG, "Initialize document: {}", doc_id);
event!(
tracing::Level::DEBUG,
"Initialize document: {}, workspace_id: {:?}",
doc_id,
self.user_service.workspace_id()
);
let collab = self
.collab_for_document(uid, doc_id, doc_state, true)
.await?;
@ -209,6 +224,8 @@ impl DocumentManager {
if let Some(mutex_document) = self.restore_document_from_removing(doc_id) {
mutex_document.start_init_sync();
}
let _ = self.create_document_instance(doc_id).await?;
Ok(())
}
@ -247,6 +264,7 @@ impl DocumentManager {
Ok(())
}
#[instrument(level = "debug", skip_all, err)]
pub async fn set_document_awareness_local_state(
&self,
doc_id: &str,