commit - 95b898ec29b08e1344a01d1d693dc0068fb166f2
commit + 38d37de2f174a9f5f7bc79467d34f4fbe7a91e8d
blob - 0ae73f956fd559ea9be022672967673a0edf858f
blob + f7ea58260efe31bcbef82617a7183340f25972da
--- src/cli.rs
+++ src/cli.rs
};
simple_logger::init_with_level(verbosity)?;
+ let data_dir = data_dir();
+ if !PathBuf::from(&data_dir).exists() {
+ debug!(
+ "No data directory exists, creating a new one: {:?}",
+ &data_dir
+ );
+ std::fs::create_dir(&data_dir)?;
+ }
+
if File::open(&args.database_path).is_err() {
debug!(
"No database file exists, creating a new one: {:?}",
}
}
+fn project_dirs() -> directories::ProjectDirs {
+ directories::ProjectDirs::from("", "", "rss-email").unwrap()
+}
+
/// Returns the base directory where all the configuration files are stored.
fn config_dir() -> PathBuf {
- directories::ProjectDirs::from("", "", "rss-email")
- .unwrap()
- .config_dir()
- .to_path_buf()
+ project_dirs().config_dir().to_path_buf()
}
+/// Returns the base directory where all the data files are stored.
+fn data_dir() -> PathBuf {
+ project_dirs().data_dir().to_path_buf()
+}
+
/// Returns the path to the database.
#[allow(dead_code)]
fn database_path() -> PathBuf {
- config_dir().join("cache.db")
+ data_dir().join("cache.db")
}
/// Returns the path to the configuration file.