mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* chore: move to latest appflowy collab version * chore: filter mapping * chore: remove mutex folder * chore: cleanup borrow checker issues * chore: fixed flowy user crate compilation errors * chore: removed parking lot crate * chore: adjusting non locking approach * chore: remove with folder method * chore: fix folder manager * chore: fixed workspace database compilation errors * chore: initialize database plugins * chore: fix locks in flowy core * chore: remove supabase * chore: async traits * chore: add mutexes in dart ffi * chore: post rebase fixes * chore: remove supabase dart code * chore: fix deadlock * chore: fix page_id is empty * chore: use data source to init collab * chore: fix user awareness test * chore: fix database deadlock * fix: initialize user awareness * chore: fix open workspace test * chore: fix import csv * chore: fix update row meta deadlock * chore: fix document size test * fix: timestamp set/get type convert * fix: calculation * chore: revert Arc to Rc * chore: attach plugin to database and database row * chore: async get row * chore: clippy * chore: fix tauri build * chore: clippy * fix: duplicate view deadlock * chore: fmt * chore: tauri build --------- Co-authored-by: nathan <nathan@appflowy.io>
80 lines
2.3 KiB
Rust
80 lines
2.3 KiB
Rust
use dotenv::dotenv;
|
|
use flowy_core::config::AppFlowyCoreConfig;
|
|
use flowy_core::{AppFlowyCore, DEFAULT_NAME};
|
|
use lib_dispatch::runtime::AFPluginRuntime;
|
|
use std::rc::Rc;
|
|
use std::sync::Mutex;
|
|
|
|
pub fn read_env() {
|
|
dotenv().ok();
|
|
|
|
let env = if cfg!(debug_assertions) {
|
|
include_str!("../env.development")
|
|
} else {
|
|
include_str!("../env.production")
|
|
};
|
|
|
|
for line in env.lines() {
|
|
if let Some((key, value)) = line.split_once('=') {
|
|
// Check if the environment variable is not already set in the system
|
|
let current_value = std::env::var(key).unwrap_or_default();
|
|
if current_value.is_empty() {
|
|
std::env::set_var(key, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn init_appflowy_core() -> MutexAppFlowyCore {
|
|
let config_json = include_str!("../tauri.conf.json");
|
|
let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap();
|
|
|
|
let app_version = config
|
|
.package
|
|
.version
|
|
.clone()
|
|
.map(|v| v.to_string())
|
|
.unwrap_or_else(|| "0.5.8".to_string());
|
|
let app_version =
|
|
semver::Version::parse(&app_version).unwrap_or_else(|_| semver::Version::new(0, 5, 8));
|
|
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
|
|
if cfg!(debug_assertions) {
|
|
data_path.push("data_dev");
|
|
} else {
|
|
data_path.push("data");
|
|
}
|
|
|
|
let custom_application_path = data_path.to_str().unwrap().to_string();
|
|
let application_path = data_path.to_str().unwrap().to_string();
|
|
let device_id = uuid::Uuid::new_v4().to_string();
|
|
|
|
read_env();
|
|
std::env::set_var("RUST_LOG", "trace");
|
|
|
|
let config = AppFlowyCoreConfig::new(
|
|
app_version,
|
|
custom_application_path,
|
|
application_path,
|
|
device_id,
|
|
"tauri".to_string(),
|
|
DEFAULT_NAME.to_string(),
|
|
)
|
|
.log_filter("trace", vec!["appflowy_tauri".to_string()]);
|
|
|
|
let runtime = Rc::new(AFPluginRuntime::new().unwrap());
|
|
let cloned_runtime = runtime.clone();
|
|
runtime.block_on(async move {
|
|
MutexAppFlowyCore::new(AppFlowyCore::new(config, cloned_runtime, None).await)
|
|
})
|
|
}
|
|
|
|
pub struct MutexAppFlowyCore(pub Rc<Mutex<AppFlowyCore>>);
|
|
|
|
impl MutexAppFlowyCore {
|
|
fn new(appflowy_core: AppFlowyCore) -> Self {
|
|
Self(Rc::new(Mutex::new(appflowy_core)))
|
|
}
|
|
}
|
|
unsafe impl Sync for MutexAppFlowyCore {}
|
|
unsafe impl Send for MutexAppFlowyCore {}
|