Remove dependency from arti-client to tor-config.
I'm about to make tor-config a higher-level module, so it can't be a dependency for tor-config.
This commit is contained in:
parent
727e420d5c
commit
e5c5519f7b
|
@ -98,6 +98,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"derive_builder",
|
"derive_builder",
|
||||||
|
"directories",
|
||||||
"futures",
|
"futures",
|
||||||
"hyper",
|
"hyper",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
|
@ -107,7 +108,6 @@ dependencies = [
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tor-chanmgr",
|
"tor-chanmgr",
|
||||||
"tor-circmgr",
|
"tor-circmgr",
|
||||||
"tor-config",
|
|
||||||
"tor-dirmgr",
|
"tor-dirmgr",
|
||||||
"tor-persist",
|
"tor-persist",
|
||||||
"tor-proto",
|
"tor-proto",
|
||||||
|
|
|
@ -25,13 +25,13 @@ experimental-api = []
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tor-circmgr = { path="../tor-circmgr", version = "0.0.1"}
|
tor-circmgr = { path="../tor-circmgr", version = "0.0.1"}
|
||||||
tor-chanmgr = { path="../tor-chanmgr", version = "0.0.1"}
|
tor-chanmgr = { path="../tor-chanmgr", version = "0.0.1"}
|
||||||
tor-config = { path="../tor-config", version = "0.0.1"}
|
|
||||||
tor-dirmgr = { path="../tor-dirmgr", version = "0.0.1"}
|
tor-dirmgr = { path="../tor-dirmgr", version = "0.0.1"}
|
||||||
tor-persist = { path="../tor-persist", version = "0.0.1"}
|
tor-persist = { path="../tor-persist", version = "0.0.1"}
|
||||||
tor-proto = { path="../tor-proto", version = "0.0.1"}
|
tor-proto = { path="../tor-proto", version = "0.0.1"}
|
||||||
tor-rtcompat = { path="../tor-rtcompat", version = "0.0.1"}
|
tor-rtcompat = { path="../tor-rtcompat", version = "0.0.1"}
|
||||||
|
|
||||||
derive_builder = "0.10.2"
|
derive_builder = "0.10.2"
|
||||||
|
directories = "4.0.1"
|
||||||
futures = "0.3.13"
|
futures = "0.3.13"
|
||||||
tracing = "0.1.26"
|
tracing = "0.1.26"
|
||||||
serde = { version = "1.0.124", features = ["derive"] }
|
serde = { version = "1.0.124", features = ["derive"] }
|
||||||
|
|
|
@ -94,19 +94,23 @@ pub struct TorClientConfig {
|
||||||
impl TorClientConfig {
|
impl TorClientConfig {
|
||||||
/// Returns a `TorClientConfig` using reasonably sane defaults.
|
/// Returns a `TorClientConfig` using reasonably sane defaults.
|
||||||
///
|
///
|
||||||
/// This uses `tor_config`'s definitions for `APP_LOCAL_DATA` and
|
/// This gies the same result as using `tor_config`'s definitions
|
||||||
/// `APP_CACHE` for the state and cache directories respectively.
|
/// for `APP_LOCAL_DATA` and `APP_CACHE` for the state and cache
|
||||||
|
/// directories respectively.
|
||||||
///
|
///
|
||||||
/// (On unix, this usually works out to `~/.local/share/arti` and
|
/// (On unix, this usually works out to `~/.local/share/arti` and
|
||||||
/// `~/.cache/arti`, depending on your environment. We use the
|
/// `~/.cache/arti`, depending on your environment. We use the
|
||||||
/// `directories` crate for reasonable defaults on other platforms.)
|
/// `directories` crate for reasonable defaults on other platforms.)
|
||||||
pub fn sane_defaults() -> Result<Self> {
|
pub fn sane_defaults() -> Result<Self> {
|
||||||
let state_dir = tor_config::CfgPath::new("${APP_LOCAL_DATA}".into())
|
// Note: this must stay in sync with project_dirs() in the
|
||||||
.path()
|
// tor-config crate.
|
||||||
.map_err(|e| Error::Configuration(format!("failed to find APP_LOCAL_DATA: {:?}", e)))?;
|
let dirs =
|
||||||
let cache_dir = tor_config::CfgPath::new("${APP_CACHE}".into())
|
directories::ProjectDirs::from("org", "torproject", "Arti").ok_or_else(|| {
|
||||||
.path()
|
Error::Configuration("Could not determine default directories".to_string())
|
||||||
.map_err(|e| Error::Configuration(format!("failed to find APP_CACHE: {:?}", e)))?;
|
})?;
|
||||||
|
|
||||||
|
let state_dir = dirs.data_local_dir();
|
||||||
|
let cache_dir = dirs.cache_dir();
|
||||||
|
|
||||||
Self::with_directories(state_dir, cache_dir)
|
Self::with_directories(state_dir, cache_dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,8 @@ impl std::fmt::Display for CfgPath {
|
||||||
/// Return a ProjectDirs object for the Arti project.
|
/// Return a ProjectDirs object for the Arti project.
|
||||||
fn project_dirs() -> Result<&'static ProjectDirs, Error> {
|
fn project_dirs() -> Result<&'static ProjectDirs, Error> {
|
||||||
/// lazy cell holding the ProjectDirs object.
|
/// lazy cell holding the ProjectDirs object.
|
||||||
|
// Note: this must stay in sync with sane_defaults() in the
|
||||||
|
// arti-client crate.
|
||||||
static PROJECT_DIRS: Lazy<Option<ProjectDirs>> =
|
static PROJECT_DIRS: Lazy<Option<ProjectDirs>> =
|
||||||
Lazy::new(|| ProjectDirs::from("org", "torproject", "Arti"));
|
Lazy::new(|| ProjectDirs::from("org", "torproject", "Arti"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue