!fixup 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-30 11:01:30 +10:00
parent b0ffeeab1d
commit 69f7565746
No known key found for this signature in database
GPG key ID: 30C3FC2E438ADB6E
4 changed files with 43 additions and 27 deletions

View file

@ -1,8 +1,8 @@
use crate::fs::system_data_dir;
use anyhow::{Context, Result};
use directories_next::ProjectDirs;
use libp2p::core::Multiaddr;
use libp2p::PeerId;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use url::Url;
use uuid::Uuid;
@ -135,13 +135,12 @@ pub struct MoneroParams {
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/
// Takes the default system data-dir and adds a `/cli`
impl Default for Data {
fn default() -> Self {
Data(
ProjectDirs::from("", "", "xmr-btc-swap-cli")
.map(|proj_dirs| proj_dirs.data_dir().to_path_buf())
system_data_dir()
.map(|proj_dir| Path::join(&proj_dir, "cli"))
.expect("computed valid path for data dir"),
)
}