Skip to content

Commit

Permalink
Manual rebase VI
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsan committed Aug 17, 2023
1 parent a68e938 commit 7ede0a9
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 393 deletions.
557 changes: 274 additions & 283 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ reqwest = { version = "0.11", default-features = false, features = [
"blocking",
] }
backoff = "0.4"
url = "2.3.1"
url = "2.4.0"

# rclone backend
semver = "1"
Expand All @@ -226,7 +226,7 @@ rhai = { version = "1.15", features = [
"only_i64",
] }
simplelog = "0.12"
comfy-table = "6.1.4"
comfy-table = "7.0.1"

# cache
dirs = "5"
Expand All @@ -241,19 +241,19 @@ path-dedot = "3"
dunce = "1"
gethostname = "0.4"
bytesize = "1"
itertools = "0.10"
itertools = "0.11"
humantime = "2"
clap_complete = "4"
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
once_cell = "1.17"
self_update = { version = "0.36", default-features = false, features = [
once_cell = "1.18"
self_update = { version = "0.37", default-features = false, features = [
"rustls",
"archive-tar",
"compression-flate2",
] }

# dev dependencies
rstest = "0.17"
rstest = "0.18"
quickcheck = "1"
quickcheck_macros = "1"
tempfile = "3.7"
Expand Down
2 changes: 1 addition & 1 deletion crates/rustic_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sha2 = "0.10"
xattr = "1"

[dev-dependencies]
rustup-toolchain = "0.1.4"
rustup-toolchain = "0.1.5"
rustdoc-json = "0.8.7"
public-api = "0.31.3"
rstest = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/rustic_core/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub trait ReadSourceOpen {
}

/// Trait for backends that can read from a source.
///
///
/// This trait is implemented by all backends that can read data from a source.
pub trait ReadSource {
type Open: ReadSourceOpen;
Expand All @@ -306,7 +306,7 @@ pub trait ReadSource {
}

/// Trait for backends that can write to a source.
///
///
/// This trait is implemented by all backends that can write data to a source.
pub trait WriteSource: Clone {
/// Create a new source.
Expand Down
1 change: 0 additions & 1 deletion crates/rustic_core/src/backend/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::{
},
error::{LocalErrorKind, RusticResult},
id::Id,
repository::parse_command,
};

/// Local backend, used when backing up.
Expand Down
2 changes: 1 addition & 1 deletion crates/rustic_core/src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<T: Default> Initialize<T> for BlobTypeMap<T> {
pub(crate) struct Blob {
/// The type of the blob
tpe: BlobType,

/// The id of the blob
id: Id,
}
8 changes: 2 additions & 6 deletions crates/rustic_core/src/blob/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ where
///
/// * [`TreeErrorKind::BlobIdNotFound`] - If the tree ID is not found in the backend.
/// * [`TreeErrorKind::DeserializingTreeFailed`] - If deserialization fails.
#[allow(unused)]
pub fn new(be: BE, node: &Node) -> RusticResult<Self> {
Self::new_streamer(be, node, None, true)
}
Expand Down Expand Up @@ -305,12 +306,7 @@ where
///
/// * [`TreeErrorKind::BuildingNodeStreamerFailed`] - If building the streamer fails.
/// * [`TreeErrorKind::ReadingFileStringFromGlobsFailed`] - If reading a glob file fails.
pub fn new_with_glob(
be: BE,
node: &Node,
opts: &TreeStreamerOptions,
recursive: bool,
) -> RusticResult<Self> {
pub fn new_with_glob(be: BE, node: &Node, opts: &TreeStreamerOptions) -> RusticResult<Self> {
let mut override_builder = OverrideBuilder::new("");

for g in &opts.glob {
Expand Down
14 changes: 7 additions & 7 deletions crates/rustic_core/src/chunker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ pub(crate) struct ChunkIter<R: Read + Send> {

/// The position in the buffer.
pos: usize,

/// The reader.
reader: R,

/// The predicate used to determine if a chunk is a chunk boundary.
predicate: fn(u64) -> bool,

/// The rolling hash.
rabin: Rabin64,

/// The size hint is used to optimize memory allocation; this should be an upper bound on the size.
size_hint: usize,

/// The minimum size of a chunk.
min_size: usize,

/// The maximum size of a chunk.
max_size: usize,

/// If the iterator is finished.
finished: bool,
}
Expand Down
3 changes: 1 addition & 2 deletions crates/rustic_core/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,8 @@ impl<P: ProgressBars, S: IndexedTree> Repository<P, S> {
&self,
node: &Node,
ls_opts: &LsOptions,
recursive: bool,
) -> RusticResult<impl Iterator<Item = RusticResult<(PathBuf, Node)>> + Clone> {
NodeStreamer::new_with_glob(self.index().clone(), node, ls_opts, recursive)
NodeStreamer::new_with_glob(self.index().clone(), node, ls_opts)
}

/// Restore a given [`RestorePlan`] to a local destination
Expand Down
51 changes: 23 additions & 28 deletions src/commands/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ use crate::{
{status_err, Application, RUSTIC_APP},
};
use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::{bail, Result};
use anyhow::{bail, Context, Result};
use log::{debug, info, warn};

use chrono::Local;

use merge::Merge;
use serde::Deserialize;

use rustic_core::{
BackupOpts, LocalSourceFilterOptions, LocalSourceSaveOptions, ParentOpts, PathList,
SnapshotFile, SnapshotOptions,
BackupOptions, LocalSourceFilterOptions, LocalSourceSaveOptions, ParentOptions, PathList,
SnapshotOptions,
};

/// `backup` subcommand
Expand Down Expand Up @@ -60,7 +58,7 @@ pub struct BackupCmd {

#[clap(flatten, next_help_heading = "Options for parent processing")]
#[serde(flatten)]
parent_opts: ParentOpts,
parent_opts: ParentOptions,

#[clap(flatten, next_help_heading = "Exclude options")]
#[serde(flatten)]
Expand Down Expand Up @@ -98,13 +96,6 @@ impl Runnable for BackupCmd {

impl BackupCmd {
fn inner_run(&self) -> Result<()> {
let time = Local::now();

let command: String = std::env::args_os()
.map(|s| s.to_string_lossy().to_string())
.collect::<Vec<_>>()
.join(" ");

let config = RUSTIC_APP.config();

let repo = open_repository(&config)?.to_indexed_ids()?;
Expand All @@ -123,21 +114,26 @@ impl BackupCmd {

let config_sources: Vec<_> = config_opts
.iter()
.filter_map(|opt| match PathList::from_string(&opt.source, true) {
.map(|opt| -> Result<_> {
Ok(PathList::from_string(&opt.source)?
.sanitize()
.with_context(|| {
format!("error sanitizing source=\"{}\" in config file", opt.source)
})?
.merge())
})
.filter_map(|p| match p {
Ok(paths) => Some(paths),
Err(err) => {
warn!(
"error sanitizing source=\"{}\" in config file: {err}",
opt.source
);
warn!("{err}");
None
}
})
.collect();

let sources = match (self.cli_sources.is_empty(), config_opts.is_empty()) {
(false, _) => {
let item = PathList::from_strings(&self.cli_sources, true)?;
let item = PathList::from_strings(&self.cli_sources).sanitize()?;
vec![item]
}
(true, false) => {
Expand Down Expand Up @@ -174,15 +170,14 @@ impl BackupCmd {
// merge "backup" section from config file, if given
opts.merge(config.backup.clone());

let snap = SnapshotFile::new_from_options(&opts.snap_opts, time, command.clone())?;
let backup_opts = BackupOpts {
stdin_filename: opts.stdin_filename,
as_path: opts.as_path,
parent_opts: opts.parent_opts,
ignore_save_opts: opts.ignore_save_opts,
ignore_filter_opts: opts.ignore_filter_opts,
};
let snap = repo.backup(&backup_opts, source.clone(), snap, config.global.dry_run)?;
let backup_opts = BackupOptions::default()
.stdin_filename(opts.stdin_filename)
.as_path(opts.as_path)
.parent_opts(opts.parent_opts)
.ignore_save_opts(opts.ignore_save_opts)
.ignore_filter_opts(opts.ignore_filter_opts)
.dry_run(config.global.dry_run);
let snap = repo.backup(&backup_opts, source.clone(), opts.snap_opts.to_snapshot()?)?;

if opts.json {
let mut stdout = std::io::stdout();
Expand Down
6 changes: 3 additions & 3 deletions src/commands/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use abscissa_core::{Command, Runnable, Shutdown};

use anyhow::Result;

use rustic_core::{BlobType, FileType};
use rustic_core::repofile::{BlobType, FileType};

/// `cat` subcommand
#[derive(clap::Parser, Command, Debug)]
Expand Down Expand Up @@ -64,10 +64,10 @@ impl CatCmd {
CatSubCmd::Config => repo.cat_file(FileType::Config, "")?,
CatSubCmd::Index(opt) => repo.cat_file(FileType::Index, &opt.id)?,
CatSubCmd::Snapshot(opt) => repo.cat_file(FileType::Snapshot, &opt.id)?,
// special treatment for cating blobs: read the index and use it to locate the blob
// special treatment for 'cat'ing blobs: read the index and use it to locate the blob
CatSubCmd::TreeBlob(opt) => repo.to_indexed()?.cat_blob(BlobType::Tree, &opt.id)?,
CatSubCmd::DataBlob(opt) => repo.to_indexed()?.cat_blob(BlobType::Data, &opt.id)?,
// special treatment for cating a tree within a snapshot
// special treatment for 'cat'ing a tree within a snapshot
CatSubCmd::Tree(opt) => repo
.to_indexed()?
.cat_tree(&opt.snap, |sn| config.snapshot_filter.matches(sn))?,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::{commands::open_repository, status_err, Application, RUSTIC_APP};

use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::Result;
use rustic_core::CheckOpts;
use rustic_core::CheckOptions;

/// `check` subcommand
#[derive(clap::Parser, Command, Debug)]
pub(crate) struct CheckCmd {
#[clap(flatten)]
opts: CheckOpts,
opts: CheckOptions,
}

impl Runnable for CheckCmd {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use abscissa_core::{Command, Runnable, Shutdown};

use anyhow::Result;

use rustic_core::ConfigOpts;
use rustic_core::ConfigOptions;

/// `config` subcommand
#[derive(clap::Parser, Command, Debug)]
pub(crate) struct ConfigCmd {
#[clap(flatten)]
config_opts: ConfigOpts,
config_opts: ConfigOptions,
}

impl Runnable for ConfigCmd {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use log::{error, info};
use merge::Merge;
use serde::Deserialize;

use rustic_core::{CopySnapshot, Id, KeyOpts, Open, Repository, RepositoryOptions};
use rustic_core::{CopySnapshot, Id, KeyOptions, Repository, RepositoryOptions};

/// `copy` subcommand
#[derive(clap::Parser, Command, Debug)]
Expand All @@ -26,7 +26,7 @@ pub(crate) struct CopyCmd {
init: bool,

#[clap(flatten, next_help_heading = "Key options (when using --init)")]
key_opts: KeyOpts,
key_opts: KeyOptions,
}

#[derive(Default, Clone, Debug, Deserialize, Merge)]
Expand Down
14 changes: 7 additions & 7 deletions src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::path::{Path, PathBuf};
use anyhow::{bail, Context, Result};

use rustic_core::{
BlobType, IndexedFull, LocalDestination, LocalSource, LocalSourceFilterOptions,
LocalSourceSaveOptions, Node, NodeType, ReadSourceEntry, Repository, RusticResult,
TreeStreamerOptions,
repofile::{BlobType, Node, NodeType},
IndexedFull, LocalDestination, LocalSource, LocalSourceFilterOptions, LocalSourceSaveOptions,
LsOptions, ReadSourceEntry, Repository, RusticResult,
};

/// `diff` subcommand
Expand Down Expand Up @@ -60,7 +60,7 @@ impl DiffCmd {
_ = match (id1, id2) {
(Some(id1), Some(id2)) => {
// diff between two snapshots
let snaps = repo.get_snapshots(&[id1.to_string(), id2.to_string()])?;
let snaps = repo.get_snapshots(&[id1, id2])?;

let snap1 = &snaps[0];
let snap2 = &snaps[1];
Expand All @@ -69,8 +69,8 @@ impl DiffCmd {
let node2 = repo.node_from_snapshot_and_path(snap2, path2)?;

diff(
repo.ls(&node1, &TreeStreamerOptions::default(), true)?,
repo.ls(&node2, &TreeStreamerOptions::default(), true)?,
repo.ls(&node1, &LsOptions::default())?,
repo.ls(&node2, &LsOptions::default())?,
self.no_content,
|_path, node1, node2| Ok(node1.content == node2.content),
self.metadata,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl DiffCmd {
});

diff(
repo.ls(&node1, &TreeStreamerOptions::default(), true)?,
repo.ls(&node1, &LsOptions::default())?,
src,
self.no_content,
|path, node1, _node2| identical_content_local(&local, &repo, path, node1),
Expand Down
10 changes: 5 additions & 5 deletions src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ use crate::{Application, RUSTIC_APP};

use dialoguer::Password;

use rustic_core::{ConfigOpts, KeyOpts, Repository};
use rustic_core::{ConfigOptions, KeyOptions, Repository};

/// `init` subcommand
#[derive(clap::Parser, Command, Debug)]
pub(crate) struct InitCmd {
#[clap(flatten, next_help_heading = "Key options")]
key_opts: KeyOpts,
key_opts: KeyOptions,

#[clap(flatten, next_help_heading = "Config options")]
config_opts: ConfigOpts,
config_opts: ConfigOptions,
}

impl Runnable for InitCmd {
Expand Down Expand Up @@ -48,8 +48,8 @@ impl InitCmd {

pub(crate) fn init<P, S>(
repo: Repository<P, S>,
key_opts: &KeyOpts,
config_opts: &ConfigOpts,
key_opts: &KeyOptions,
config_opts: &ConfigOptions,
) -> Result<()> {
let pass = repo.password()?.unwrap_or_else(|| {
match Password::new()
Expand Down
Loading

0 comments on commit 7ede0a9

Please sign in to comment.