Different default directories for CLI and ASB

Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap-asb
- CLI: xmr-btc-swap-cli

Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
This commit is contained in:
Daniel Karzel 2021-04-29 18:50:49 +10:00
parent c0501627c9
commit b0ffeeab1d
No known key found for this signature in database
GPG key ID: 30C3FC2E438ADB6E
5 changed files with 43 additions and 29 deletions

View file

@ -1,5 +1,5 @@
use crate::fs::default_data_dir;
use anyhow::{Context, Result};
use directories_next::ProjectDirs;
use libp2p::core::Multiaddr;
use libp2p::PeerId;
use std::path::PathBuf;
@ -134,9 +134,16 @@ pub struct MoneroParams {
#[derive(Clone, Debug)]
pub struct Data(pub PathBuf);
/// Default location for storing data for the CLI
// Linux: /home/<user>/.local/share/xmr-btc-swap-cli/
// OSX: /Users/<user>/Library/Application Support/xmr-btc-swap-cli/
impl Default for Data {
fn default() -> Self {
Data(default_data_dir().expect("computed valid path for data dir"))
Data(
ProjectDirs::from("", "", "xmr-btc-swap-cli")
.map(|proj_dirs| proj_dirs.data_dir().to_path_buf())
.expect("computed valid path for data dir"),
)
}
}