refactor backend directory

This commit is contained in:
appflowy
2021-12-21 11:13:38 +08:00
parent b04111e5a3
commit d9421f70a0
93 changed files with 700 additions and 628 deletions

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,8 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod ffi_response;
pub use ffi_response::*;
mod ffi_request;
pub use ffi_request::*;

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,5 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod subject;
pub use subject::*;

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,8 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod observable;
pub use observable::*;
mod event;
pub use event::*;

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,5 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod observable;
pub use observable::*;

View File

@ -56,7 +56,7 @@ impl DocController {
}
pub(crate) fn close(&self, doc_id: &str) -> Result<(), FlowyError> {
tracing::debug!("Close doc {}", doc_id);
tracing::debug!("Close document {}", doc_id);
self.open_cache.remove(doc_id);
self.ws_handlers.remove_handler(doc_id);
Ok(())
@ -114,7 +114,7 @@ impl DocController {
fn make_rev_manager(&self, doc_id: &str, pool: Arc<ConnectionPool>) -> Result<RevisionManager, FlowyError> {
// Opti: require upgradable_read lock and then upgrade to write lock using
// RwLockUpgradableReadGuard::upgrade(xx) of ws
// let doc = self.read_doc(doc_id, pool.clone()).await?;
// let document = self.read_doc(doc_id, pool.clone()).await?;
let user_id = self.user.user_id()?;
let cache = Arc::new(RevisionCache::new(&user_id, doc_id, pool));
Ok(RevisionManager::new(&user_id, doc_id, cache))

View File

@ -20,7 +20,7 @@ use flowy_collaboration::{
use flowy_error::{internal_error, FlowyError, FlowyResult};
use lib_infra::future::FutureResult;
use lib_ot::{
revision::{RevType, Revision, RevisionRange},
revision::{Revision, RevisionRange},
rich_text::RichTextDelta,
};
use lib_ws::WSConnectState;
@ -194,7 +194,7 @@ pub(crate) async fn handle_push_rev(
bytes: Bytes,
) -> FlowyResult<Option<Revision>> {
// Transform the revision
let (ret, rx) = oneshot::channel::<CollaborateResult<TransformDeltas>>();
let (_ret, _rx) = oneshot::channel::<CollaborateResult<TransformDeltas>>();
let revision = Revision::try_from(bytes)?;
let delta = RichTextDelta::from_bytes(&revision.delta_data)?;
let server_rev_id = revision.rev_id;
@ -217,10 +217,10 @@ pub(crate) async fn handle_push_rev(
ret,
};
let _ = edit_cmd_tx.send(msg);
let md5 = rx.await.map_err(internal_error)??;
let _md5 = rx.await.map_err(internal_error)??;
// update rev id
rev_manager.update_rev_id_counter_value(server_rev_id.clone().into());
rev_manager.update_rev_id_counter_value(server_rev_id);
// let (local_base_rev_id, local_rev_id) = rev_manager.next_rev_id();
// let delta_data = client_prime.to_bytes();
// // save the revision

View File

@ -64,7 +64,7 @@ impl FileManager {
pub(crate) fn create_file(&mut self, id: &str, dir: &str, text: &str) -> Result<PathBuf, FileError> {
let path = PathBuf::from(format!("{}/{}", dir, id));
let file_id: FileId = id.to_owned().into();
tracing::info!("Create doc at: {:?}", path);
tracing::info!("Create document at: {:?}", path);
let _ = self.save_new(&path, text, &file_id)?;
Ok(path)
}

View File

@ -11,7 +11,7 @@ impl ResponseMiddleware for DocMiddleware {
fn receive_response(&self, token: &Option<String>, response: &FlowyResponse) {
if let Some(error) = &response.error {
if error.is_unauthorized() {
log::error!("doc user is unauthorized");
log::error!("document user is unauthorized");
match token {
None => {},

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,5 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod errors;
pub use errors::*;

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,8 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod network_state;
pub use network_state::*;
mod event;
pub use event::*;

View File

@ -42,7 +42,7 @@ impl DocumentUser for DocumentUserImpl {
.user_dir()
.map_err(|e| FlowyError::unauthorized().context(e))?;
let doc_dir = format!("{}/doc", dir);
let doc_dir = format!("{}/document", dir);
if !Path::new(&doc_dir).exists() {
let _ = std::fs::create_dir_all(&doc_dir)?;
}

View File

@ -0,0 +1,4 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod model;
pub use model::*;

View File

@ -0,0 +1,8 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod observable;
pub use observable::*;
mod event;
pub use event::*;