Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: ensure path

Nathan6886261692ac
diff --git a/frontend/rust-lib/flowy-core/src/config.rs b/frontend/rust-lib/flowy-core/src/config.rs
index 27f658de8d..2bad578627 100644
--- a/frontend/rust-lib/flowy-core/src/config.rs
+++ b/frontend/rust-lib/flowy-core/src/config.rs
@@ -29,7 +29,25 @@ pub struct AppFlowyCoreConfig {
pub(crate) log_filter: String,
pub cloud_config: Option<AFCloudConfiguration>,
}
+impl AppFlowyCoreConfig {
+ pub fn ensure_path(&self) {
+ let create_if_needed = |path_str: &str, label: &str| {
+ let dir = std::path::Path::new(path_str);
+ if !dir.exists() {
+ match std::fs::create_dir_all(dir) {
+ Ok(_) => info!("Created {} path: {}", label, path_str),
+ Err(err) => error!(
+ "Failed to create {} path: {}. Error: {}",
+ label, path_str, err
+ ),
+ }
+ }
+ };
+ create_if_needed(&self.storage_path, "storage");
+ create_if_needed(&self.application_path, "application");
+ }
+}
impl fmt::Debug for AppFlowyCoreConfig {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("AppFlowy Configuration");
diff --git a/frontend/rust-lib/flowy-core/src/lib.rs b/frontend/rust-lib/flowy-core/src/lib.rs
index 1562c44a22..79a889f86f 100644
--- a/frontend/rust-lib/flowy-core/src/lib.rs
+++ b/frontend/rust-lib/flowy-core/src/lib.rs
@@ -105,6 +105,8 @@ impl AppFlowyCore {
#[instrument(skip(config, runtime))]
async fn init(config: AppFlowyCoreConfig, runtime: Arc<AFPluginRuntime>) -> Self {
+ config.ensure_path();
+
// Init the key value database
let store_preference = Arc::new(KVStorePreferences::new(&config.storage_path).unwrap());
info!("🔥{:?}", &config);