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
2 changes: 1 addition & 1 deletion crates/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,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.0", 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,7 +1,7 @@
//! This module contains [`BackendOptions`] and helpers to choose a backend from a given url.
use anyhow::{anyhow, Result};
use derive_setters::Setters;
use std::{collections::HashMap, sync::Arc};
use std::{collections::BTreeMap, sync::Arc};
use strum_macros::{Display, EnumString};

#[allow(unused_imports)]
Expand Down Expand Up @@ -51,18 +51,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 @@ -107,7 +107,7 @@ impl BackendOptions {
fn get_backend(
&self,
repo_string: Option<&String>,
options: HashMap<String, String>,
options: BTreeMap<String, String>,
) -> Result<Option<Arc<dyn WriteBackend>>> {
repo_string
.map(|string| {
Expand Down Expand Up @@ -137,7 +137,7 @@ pub trait BackendChoice {
fn to_backend(
&self,
location: BackendLocation,
options: Option<HashMap<String, String>>,
options: Option<BTreeMap<String, String>>,
) -> Result<Arc<dyn WriteBackend>>;
}

Expand Down Expand Up @@ -175,7 +175,7 @@ impl BackendChoice for SupportedBackend {
fn to_backend(
&self,
location: BackendLocation,
options: Option<HashMap<String, String>>,
options: Option<BTreeMap<String, String>>,
) -> Result<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, path::PathBuf, str::FromStr, sync::OnceLock};
use std::{collections::BTreeMap, path::PathBuf, str::FromStr, sync::OnceLock};

use anyhow::{anyhow, Error, Result};
use bytes::Bytes;
Expand Down Expand Up @@ -74,7 +74,7 @@ impl OpenDALBackend {
/// # Returns
///
/// A new `OpenDAL` backend.
pub fn new(path: impl AsRef<str>, options: HashMap<String, String>) -> Result<Self> {
pub fn new(path: impl AsRef<str>, options: BTreeMap<String, String>) -> Result<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 @@ -318,7 +318,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 @@ -127,7 +127,7 @@
///
/// If the rclone command is not found.
// TODO: This should be an error, not a panic.
pub fn new(url: impl AsRef<str>, options: HashMap<String, String>) -> Result<Self> {
pub fn new(url: impl AsRef<str>, options: BTreeMap<String, String>) -> Result<Self> {

Check warning on line 130 in crates/backend/src/rclone.rs

View check run for this annotation

Codecov / codecov/patch

crates/backend/src/rclone.rs#L130

Added line #L130 was not covered by tests
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.0", optional = true }

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