Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(deps)!: upgrade to new conflate version #300

Merged
merged 8 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ url = "2.5.2"

# cli support
clap = { version = "4.5.19", optional = true, features = ["derive", "env", "wrap_help"] }
conflate = { version = "0.2.0", optional = true }
conflate = { version = "0.3.1", optional = true }

# local backend
aho-corasick = { workspace = true }
Expand Down
20 changes: 10 additions & 10 deletions crates/backend/src/choose.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module contains [`BackendOptions`] and helpers to choose a backend from a given url.
use derive_setters::Setters;
use std::{collections::HashMap, sync::Arc};
use std::{collections::BTreeMap, sync::Arc};
use strum_macros::{Display, EnumString};

use rustic_core::{ErrorKind, RepositoryBackends, RusticError, RusticResult, WriteBackend};
Expand Down Expand Up @@ -48,18 +48,18 @@ pub struct BackendOptions {

/// Other options for this repository (hot and cold part)
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))]
pub options: HashMap<String, String>,
#[cfg_attr(feature = "merge", merge(strategy = conflate::btreemap::append_or_ignore))]
pub options: BTreeMap<String, String>,

/// Other options for the hot repository
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))]
pub options_hot: HashMap<String, String>,
#[cfg_attr(feature = "merge", merge(strategy = conflate::btreemap::append_or_ignore))]
pub options_hot: BTreeMap<String, String>,

/// Other options for the cold repository
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = conflate::hashmap::ignore))]
pub options_cold: HashMap<String, String>,
#[cfg_attr(feature = "merge", merge(strategy = conflate::btreemap::append_or_ignore))]
pub options_cold: BTreeMap<String, String>,
}

impl BackendOptions {
Expand Down Expand Up @@ -109,7 +109,7 @@ impl BackendOptions {
fn get_backend(
&self,
repo_string: Option<&String>,
options: HashMap<String, String>,
options: BTreeMap<String, String>,
) -> RusticResult<Option<Arc<dyn WriteBackend>>> {
repo_string
.map(|string| {
Expand Down Expand Up @@ -142,7 +142,7 @@ pub trait BackendChoice {
fn to_backend(
&self,
location: BackendLocation,
options: Option<HashMap<String, String>>,
options: Option<BTreeMap<String, String>>,
) -> RusticResult<Arc<dyn WriteBackend>>;
}

Expand Down Expand Up @@ -180,7 +180,7 @@ impl BackendChoice for SupportedBackend {
fn to_backend(
&self,
location: BackendLocation,
options: Option<HashMap<String, String>>,
options: Option<BTreeMap<String, String>>,
) -> RusticResult<Arc<dyn WriteBackend>> {
let options = options.unwrap_or_default();

Expand Down
6 changes: 3 additions & 3 deletions crates/backend/src/opendal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// `OpenDAL` backend for rustic.
use std::{collections::HashMap, str::FromStr, sync::OnceLock};
use std::{collections::BTreeMap, str::FromStr, sync::OnceLock};

use bytes::Bytes;
use bytesize::ByteSize;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl OpenDALBackend {
/// # Returns
///
/// A new `OpenDAL` backend.
pub fn new(path: impl AsRef<str>, options: HashMap<String, String>) -> RusticResult<Self> {
pub fn new(path: impl AsRef<str>, options: BTreeMap<String, String>) -> RusticResult<Self> {
let max_retries = match options.get("retry").map(String::as_str) {
Some("false" | "off") => 0,
None | Some("default") => constants::DEFAULT_RETRY,
Expand Down Expand Up @@ -521,7 +521,7 @@ mod tests {
#[derive(Deserialize)]
struct TestCase {
path: String,
options: HashMap<String, String>,
options: BTreeMap<String, String>,
}

let test: TestCase = toml::from_str(&fs::read_to_string(test_case)?)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/backend/src/rclone.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
collections::HashMap,
collections::BTreeMap,
io::{BufRead, BufReader},
process::{Child, Command, Stdio},
thread::JoinHandle,
Expand Down Expand Up @@ -144,7 +144,7 @@ impl RcloneBackend {
/// * If the rclone command is not found.
// TODO: This should be an error, not a panic.
#[allow(clippy::too_many_lines)]
pub fn new(url: impl AsRef<str>, options: HashMap<String, String>) -> RusticResult<Self> {
pub fn new(url: impl AsRef<str>, options: BTreeMap<String, String>) -> RusticResult<Self> {
let rclone_command = options.get("rclone-command");
let use_password = options
.get("use-password")
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dirs = "5.0.1"

# cli support
clap = { version = "4.5.19", optional = true, features = ["derive", "env", "wrap_help"] }
conflate = { version = "0.2.0", optional = true }
conflate = { version = "0.3.1", optional = true }

# vfs support
dav-server = { version = "0.7.0", default-features = false, optional = true }
Expand Down
Loading