From a4146d240268622b2e54d01a4659bb0613d11ab6 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 8 Oct 2019 18:05:30 +0200 Subject: [PATCH 1/4] fix: use correct system directories for configs and packages --- src/config/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index ce1f192..4783d15 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -361,13 +361,13 @@ impl ConfigSet { } pub fn get_default_config_dir() -> PathBuf { - let home_dir = dirs::home_dir().expect("Unable to get home directory"); - home_dir.join(".espanso") + let config_dir = dirs::config_dir().expect("Unable to get config directory"); + config_dir.join("espanso") } pub fn get_default_packages_dir() -> PathBuf { - let espanso_dir = ConfigSet::get_default_config_dir(); - espanso_dir.join(PACKAGES_FOLDER_NAME) + let data_dir = dirs::data_local_dir().expect("Unable to get data directory"); + data_dir.join(PACKAGES_FOLDER_NAME) } } From fe1c3afa82d97e4416ed0d25babfa079bf4892bd Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 8 Oct 2019 18:33:25 +0200 Subject: [PATCH 2/4] fix: use local data dir for context module, too --- src/context/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context/mod.rs b/src/context/mod.rs index bbc1d9e..6827c69 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -36,7 +36,7 @@ pub trait Context { } pub fn get_data_dir() -> PathBuf { - let data_dir = dirs::data_dir().expect("Can't obtain data_dir(), terminating."); + let data_dir = dirs::data_local_dir().expect("Can't obtain data_dir(), terminating."); let espanso_dir = data_dir.join("espanso"); create_dir_all(&espanso_dir).expect("Error creating espanso data directory"); espanso_dir From c0f4fe04ac9162ddeb36c2f87fe4eca7bc226df5 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 8 Oct 2019 18:33:46 +0200 Subject: [PATCH 3/4] fix: create packages directory in correct path --- src/config/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 4783d15..d2b812b8 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -320,13 +320,13 @@ impl ConfigSet { } pub fn load_default() -> Result { - let espanso_dir = ConfigSet::get_default_config_dir(); + let config_dir = ConfigSet::get_default_config_dir(); - // Create the espanso dir if id doesn't exist - let res = create_dir_all(espanso_dir.as_path()); + // Create the espanso dir if it doesn't exist + let res = create_dir_all(config_dir.as_path()); if res.is_ok() { - let default_file = espanso_dir.join(DEFAULT_CONFIG_FILE_NAME); + let default_file = config_dir.join(DEFAULT_CONFIG_FILE_NAME); // If config file does not exist, create one from template if !default_file.exists() { @@ -338,7 +338,7 @@ impl ConfigSet { // Create auxiliary directories - let user_config_dir = espanso_dir.join(USER_CONFIGS_FOLDER_NAME); + let user_config_dir = config_dir.join(USER_CONFIGS_FOLDER_NAME); if !user_config_dir.exists() { let res = create_dir_all(user_config_dir.as_path()); if res.is_err() { @@ -346,7 +346,7 @@ impl ConfigSet { } } - let packages_dir = espanso_dir.join(PACKAGES_FOLDER_NAME); + let packages_dir = ConfigSet::get_default_packages_dir().join(PACKAGES_FOLDER_NAME); if !packages_dir.exists() { let res = create_dir_all(packages_dir.as_path()); if res.is_err() { @@ -354,7 +354,7 @@ impl ConfigSet { } } - return ConfigSet::load(espanso_dir.as_path()) + return ConfigSet::load(config_dir.as_path()) } Err(ConfigLoadError::UnableToCreateDefaultConfig) @@ -366,7 +366,7 @@ impl ConfigSet { } pub fn get_default_packages_dir() -> PathBuf { - let data_dir = dirs::data_local_dir().expect("Unable to get data directory"); + let data_dir = dirs::data_local_dir().expect("Unable to get package directory"); data_dir.join(PACKAGES_FOLDER_NAME) } } From 59206b6384502278d7e40f97b1c8e6b99b324276 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 8 Oct 2019 18:59:31 +0200 Subject: [PATCH 4/4] fix: put package directory in config path. --- src/config/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index d2b812b8..6838a39 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -366,7 +366,7 @@ impl ConfigSet { } pub fn get_default_packages_dir() -> PathBuf { - let data_dir = dirs::data_local_dir().expect("Unable to get package directory"); + let data_dir = ConfigSet::get_default_config_dir(); data_dir.join(PACKAGES_FOLDER_NAME) } }