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

fix(deps): update rustic_core and other dependencies and fix merge precedence #1282

Merged
merged 7 commits into from
Oct 2, 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
162 changes: 76 additions & 86 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ rustdoc-args = ["--document-private-items", "--generate-link-to-definition"]

[dependencies]
abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] }
rustic_backend = { version = "0.3.0", features = ["cli"] }
rustic_core = { version = "0.4.0", features = ["cli"] }
rustic_backend = { version = "0.4.0", features = ["cli"] }
rustic_core = { version = "0.5.0", features = ["cli"] }

# allocators
jemallocator-global = { version = "0.3.2", optional = true }
Expand All @@ -69,7 +69,7 @@ thiserror = "1"
# serialization
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1"
serde_with = { version = "3.9", features = ["base64"] }
serde_with = { version = "3.10", features = ["base64"] }

# other dependencies
aho-corasick = "1.1.3"
Expand All @@ -85,6 +85,7 @@ bytesize = "1"
cached = "0.53.1"
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
clap_complete = "4"
conflate = "0.2"
convert_case = "0.6.0"
dialoguer = "0.11.0"
directories = "5"
Expand All @@ -94,8 +95,7 @@ human-panic = "2.0.1"
humantime = "2"
indicatif = "0.17"
itertools = "0.13"
merge = "0.1"
once_cell = "1.19"
once_cell = "1.20"
open = "5.1.2"
self_update = { version = "0.41", default-features = false, optional = true, features = ["rustls", "archive-tar", "compression-flate2"] }
toml = "0.8"
Expand All @@ -109,12 +109,12 @@ pretty_assertions = "1.4"
quickcheck = "1"
quickcheck_macros = "1"
rstest = "0.23"
rustic_testing = "0.2.1"
tempfile = "3.12"
rustic_testing = "0.2.2"
tempfile = "3.13"
toml = "0.8"

[target.'cfg(not(windows))'.dependencies]
libc = "0.2.158"
libc = "0.2.159"
# cargo-binstall support
# https://github.com/cargo-bins/cargo-binstall/blob/HEAD/SUPPORT.md
[package.metadata.binstall]
Expand Down
14 changes: 8 additions & 6 deletions src/commands/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::{bail, Context, Result};
use clap::ValueHint;
use comfy_table::Cell;
use conflate::Merge;
use log::{debug, info, warn};
use merge::Merge;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

Expand Down Expand Up @@ -47,10 +47,12 @@ pub struct BackupCmd {

/// Start the given command and use its output as stdin
#[clap(long, value_name = "COMMAND")]
#[merge(strategy=conflate::option::overwrite_none)]
stdin_command: Option<CommandInput>,

/// Manually set backup path in snapshot
#[clap(long, value_name = "PATH", value_hint = ValueHint::DirPath)]
#[merge(strategy=conflate::option::overwrite_none)]
as_path: Option<PathBuf>,

/// Ignore save options
Expand All @@ -60,27 +62,27 @@ pub struct BackupCmd {

/// Don't scan the backup source for its size - this disables ETA estimation for backup.
#[clap(long)]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
pub no_scan: bool,

/// Output generated snapshot in json format
#[clap(long)]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
json: bool,

/// Show detailed information about generated snapshot
#[clap(long, conflicts_with = "json")]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
long: bool,

/// Don't show any output
#[clap(long, conflicts_with_all = ["json", "long"])]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
quiet: bool,

/// Initialize repository, if it doesn't exist yet
#[clap(long)]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
init: bool,

/// Parent processing options
Expand Down
4 changes: 2 additions & 2 deletions src/commands/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
};
use abscissa_core::{config::Override, Command, FrameworkError, Runnable, Shutdown};
use anyhow::{bail, Result};
use conflate::Merge;
use log::{error, info, log, Level};
use merge::Merge;
use serde::{Deserialize, Serialize};

use rustic_core::{CopySnapshot, Id, KeyOptions};
Expand All @@ -30,7 +30,7 @@ pub struct CopyCmd {

/// Target repository (can be specified multiple times)
#[clap(long = "target", value_name = "TARGET")]
#[merge(strategy = merge::vec::overwrite_empty)]
#[merge(strategy=conflate::vec::overwrite_empty)]
targets: Vec<String>,

/// Key options (when using --init)
Expand Down
5 changes: 3 additions & 2 deletions src/commands/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use abscissa_core::{Command, FrameworkError, Runnable};
use anyhow::Result;

use chrono::Local;
use merge::Merge;
use conflate::Merge;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};

Expand Down Expand Up @@ -70,11 +70,12 @@ pub struct ForgetOptions {
/// Group snapshots by any combination of host,label,paths,tags (default: "host,label,paths")
#[clap(long, short = 'g', value_name = "CRITERION")]
#[serde_as(as = "Option<DisplayFromStr>")]
#[merge(strategy=conflate::option::overwrite_none)]
group_by: Option<SnapshotGroupCriterion>,

/// Also prune the repository
#[clap(long)]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
prune: bool,

/// Snapshot filter options
Expand Down
10 changes: 4 additions & 6 deletions src/commands/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ impl AddCmd {
let repo = open_repository(&config.repository)?;

// create new Repository options which just contain password information
let pass_opts = RepositoryOptions {
password: self.new_password.clone(),
password_file: self.new_password_file.clone(),
password_command: self.new_password_command.clone(),
..Default::default()
};
let mut pass_opts = RepositoryOptions::default();
pass_opts.password = self.new_password.clone();
pass_opts.password_file = self.new_password_file.clone();
pass_opts.password_command = self.new_password_command.clone();

let pass = pass_opts
.evaluate_password()
Expand Down
18 changes: 9 additions & 9 deletions src/commands/tui/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ impl<'a, P: ProgressBars, S: IndexedFull> Restore<'a, P, S> {
}
self.dest = dest;
let dest = LocalDestination::new(&self.dest, true, !self.node.is_dir())?;

// for restore, always recurse into tree
let ls_opts = LsOptions {
recursive: true,
..Default::default()
};
let mut ls_opts = LsOptions::default();
ls_opts.recursive = true;

let ls = self.repo.ls(&self.node, &ls_opts)?;

let plan = self.repo.prepare_restore(&self.opts, ls, &dest, dry_run)?;
Expand All @@ -68,14 +68,14 @@ impl<'a, P: ProgressBars, S: IndexedFull> Restore<'a, P, S> {
// restore using the plan
//
// Note: This currently runs `prepare_restore` again and doesn't use `plan`
// TODO: Fix when restore is changed such that `prepare_restore` is always dry_run and all modification is don in `restore`
// TODO: Fix when restore is changed such that `prepare_restore` is always dry_run and all modification is done in `restore`
fn restore(&self, _plan: RestorePlan) -> Result<()> {
let dest = LocalDestination::new(&self.dest, true, !self.node.is_dir())?;

// for restore, always recurse into tree
let ls_opts = LsOptions {
recursive: true,
..Default::default()
};
let mut ls_opts = LsOptions::default();
ls_opts.recursive = true;

let ls = self.repo.ls(&self.node, &ls_opts)?;
let plan = self
.repo
Expand Down
9 changes: 7 additions & 2 deletions src/commands/webdav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{net::ToSocketAddrs, str::FromStr};
use crate::{commands::open_repository_indexed, status_err, Application, RusticConfig, RUSTIC_APP};
use abscissa_core::{config::Override, Command, FrameworkError, Runnable, Shutdown};
use anyhow::{anyhow, Result};
use conflate::Merge;
use dav_server::{warp::dav_handler, DavHandler};
use merge::Merge;
use serde::{Deserialize, Serialize};

use rustic_core::vfs::{FilePolicy, IdenticalSnapshot, Latest, Vfs};
Expand All @@ -19,27 +19,32 @@ use rustic_core::vfs::{FilePolicy, IdenticalSnapshot, Latest, Vfs};
pub struct WebDavCmd {
/// Address to bind the webdav server to. [default: "localhost:8000"]
#[clap(long, value_name = "ADDRESS")]
#[merge(strategy=conflate::option::overwrite_none)]
address: Option<String>,

/// The path template to use for snapshots. {id}, {id_long}, {time}, {username}, {hostname}, {label}, {tags}, {backup_start}, {backup_end} are replaced. [default: "[{hostname}]/[{label}]/{time}"]
#[clap(long)]
#[merge(strategy=conflate::option::overwrite_none)]
path_template: Option<String>,

/// The time template to use to display times in the path template. See https://docs.rs/chrono/latest/chrono/format/strftime/index.html for format options. [default: "%Y-%m-%d_%H-%M-%S"]
#[clap(long)]
#[merge(strategy=conflate::option::overwrite_none)]
time_template: Option<String>,

/// Use symlinks. This may not be supported by all WebDAV clients
#[clap(long)]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
symlinks: bool,

/// How to handle access to files. [default: "forbidden" for hot/cold repositories, else "read"]
#[clap(long)]
#[merge(strategy=conflate::option::overwrite_none)]
file_access: Option<String>,

/// Specify directly which snapshot/path to serve
#[clap(value_name = "SNAPSHOT[:PATH]")]
#[merge(strategy=conflate::option::overwrite_none)]
snapshot_path: Option<String>,
}

Expand Down
18 changes: 7 additions & 11 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use abscissa_core::config::Config;
use abscissa_core::path::AbsPathBuf;
use abscissa_core::FrameworkError;
use clap::{Parser, ValueHint};
use conflate::Merge;
use directories::ProjectDirs;
use itertools::Itertools;
use log::Level;
use merge::Merge;
use rustic_backend::BackendOptions;
use rustic_core::RepositoryOptions;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -136,21 +136,22 @@ pub struct GlobalOptions {
value_name = "PROFILE",
env = "RUSTIC_USE_PROFILE"
)]
#[merge(strategy = merge::vec::append)]
#[merge(strategy=conflate::vec::append)]
pub use_profiles: Vec<String>,

/// Only show what would be done without modifying anything. Does not affect read-only commands.
#[clap(long, short = 'n', global = true, env = "RUSTIC_DRY_RUN")]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
pub dry_run: bool,

/// Check if index matches pack files and read pack headers if neccessary
#[clap(long, global = true, env = "RUSTIC_CHECK_INDEX")]
#[merge(strategy = merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
pub check_index: bool,

/// Use this log level [default: info]
#[clap(long, global = true, env = "RUSTIC_LOG_LEVEL")]
#[merge(strategy=conflate::option::overwrite_none)]
pub log_level: Option<String>,

/// Write log messages to the given file instead of printing them.
Expand All @@ -159,6 +160,7 @@ pub struct GlobalOptions {
///
/// Warnings and errors are still additionally printed unless they are ignored by `--log-level`
#[clap(long, global = true, env = "RUSTIC_LOG_FILE", value_name = "LOGFILE", value_hint = ValueHint::FilePath)]
#[merge(strategy=conflate::option::overwrite_none)]
pub log_file: Option<PathBuf>,

/// Settings to customize progress bars
Expand All @@ -168,16 +170,10 @@ pub struct GlobalOptions {

/// List of environment variables to set (only in config file)
#[clap(skip)]
#[merge(strategy = extend)]
#[merge(strategy = conflate::hashmap::ignore)]
pub env: HashMap<String, String>,
}

/// Extend the contents of a [`HashMap`] with the contents of another
/// [`HashMap`] with the same key and value types.
fn extend(left: &mut HashMap<String, String>, right: HashMap<String, String>) {
left.extend(right);
}

/// Get the paths to the config file
///
/// # Arguments
Expand Down
5 changes: 3 additions & 2 deletions src/config/progress_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{borrow::Cow, fmt::Write, time::Duration};
use indicatif::{HumanDuration, ProgressBar, ProgressState, ProgressStyle};

use clap::Parser;
use merge::Merge;
use conflate::Merge;

use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
Expand All @@ -19,7 +19,7 @@ use rustic_core::{Progress, ProgressBars};
pub struct ProgressOptions {
/// Don't show any progress bar
#[clap(long, global = true, env = "RUSTIC_NO_PROGRESS")]
#[merge(strategy=merge::bool::overwrite_false)]
#[merge(strategy=conflate::bool::overwrite_false)]
pub no_progress: bool,

/// Interval to update progress bars
Expand All @@ -31,6 +31,7 @@ pub struct ProgressOptions {
conflicts_with = "no_progress"
)]
#[serde_as(as = "Option<DisplayFromStr>")]
#[merge(strategy=conflate::option::overwrite_none)]
pub progress_interval: Option<humantime::Duration>,
}

Expand Down
12 changes: 7 additions & 5 deletions src/filtering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rustic_core::{repofile::SnapshotFile, StringList};
use std::{error::Error, str::FromStr};

use cached::proc_macro::cached;
use conflate::Merge;
use rhai::{serde::to_dynamic, Dynamic, Engine, FnPtr, AST};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
Expand Down Expand Up @@ -55,34 +56,35 @@ impl SnapshotFn {
}

#[serde_as]
#[derive(Clone, Default, Debug, Serialize, Deserialize, merge::Merge, clap::Parser)]
#[derive(Clone, Default, Debug, Serialize, Deserialize, Merge, clap::Parser)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
pub struct SnapshotFilter {
/// Hostname to filter (can be specified multiple times)
#[clap(long = "filter-host", global = true, value_name = "HOSTNAME")]
#[merge(strategy=merge::vec::overwrite_empty)]
#[merge(strategy=conflate::vec::overwrite_empty)]
filter_hosts: Vec<String>,

/// Label to filter (can be specified multiple times)
#[clap(long = "filter-label", global = true, value_name = "LABEL")]
#[merge(strategy=merge::vec::overwrite_empty)]
#[merge(strategy=conflate::vec::overwrite_empty)]
filter_labels: Vec<String>,

/// Path list to filter (can be specified multiple times)
#[clap(long, global = true, value_name = "PATH[,PATH,..]")]
#[serde_as(as = "Vec<DisplayFromStr>")]
#[merge(strategy=merge::vec::overwrite_empty)]
#[merge(strategy=conflate::vec::overwrite_empty)]
filter_paths: Vec<StringList>,

/// Tag list to filter (can be specified multiple times)
#[clap(long, global = true, value_name = "TAG[,TAG,..]")]
#[serde_as(as = "Vec<DisplayFromStr>")]
#[merge(strategy=merge::vec::overwrite_empty)]
#[merge(strategy=conflate::vec::overwrite_empty)]
filter_tags: Vec<StringList>,

/// Function to filter snapshots
#[clap(long, global = true, value_name = "FUNC")]
#[serde_as(as = "Option<DisplayFromStr>")]
#[merge(strategy=conflate::option::overwrite_none)]
filter_fn: Option<String>,
}

Expand Down