Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rustic-rs/rustic_core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f707f188c979aac35d92ce17534351f42147de52
Choose a base ref
..
head repository: rustic-rs/rustic_core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 08582da9f91036520fe74e7dfb048819f47b06a3
Choose a head ref
Showing with 15 additions and 12 deletions.
  1. +5 −5 crates/backend/src/choose.rs
  2. +1 −1 crates/core/src/archiver/parent.rs
  3. +7 −1 crates/core/src/backend.rs
  4. +2 −5 crates/core/tests/integration.rs
10 changes: 5 additions & 5 deletions crates/backend/src/choose.rs
Original file line number Diff line number Diff line change
@@ -51,17 +51,17 @@ pub struct BackendOptions {

/// Other options for this repository (hot and cold part)
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = overwrite))]
#[cfg_attr(feature = "merge", merge(strategy = extend))]
pub options: HashMap<String, String>,

/// Other options for the hot repository
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = overwrite))]
#[cfg_attr(feature = "merge", merge(strategy = extend))]
pub options_hot: HashMap<String, String>,

/// Other options for the cold repository
#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = overwrite))]
#[cfg_attr(feature = "merge", merge(strategy = extend))]
pub options_cold: HashMap<String, String>,
}

@@ -74,8 +74,8 @@ pub struct BackendOptions {
/// * `left` - The left value
/// * `right` - The right value
#[cfg(feature = "merge")]
pub fn overwrite<T>(left: &mut T, right: T) {
*left = right;
pub fn extend<A, T: Extend<A> + IntoIterator<Item = A>>(left: &mut T, right: T) {
left.extend(right)
}

impl BackendOptions {
2 changes: 1 addition & 1 deletion crates/core/src/archiver/parent.rs
Original file line number Diff line number Diff line change
@@ -279,7 +279,7 @@ impl Parent {
let parent = match parent {
ParentResult::Matched(p_node) => {
if p_node.content.iter().flatten().all(|id| index.has_data(id)) {
node.content = Some(p_node.content.iter().flatten().copied().collect());
node.content = p_node.content.clone();
ParentResult::Matched(())
} else {
warn!(
8 changes: 7 additions & 1 deletion crates/core/src/backend.rs
Original file line number Diff line number Diff line change
@@ -482,7 +482,7 @@ impl RepositoryBackends {
pub mod in_memory_backend {
use std::{collections::BTreeMap, sync::RwLock};

use anyhow::{anyhow, bail, Result};
use anyhow::{bail, Result};
use bytes::Bytes;
use enum_map::EnumMap;

@@ -500,6 +500,12 @@ pub mod in_memory_backend {
}
}

impl Default for InMemoryBackend {
fn default() -> Self {
Self::new()
}
}

impl ReadBackend for InMemoryBackend {
fn location(&self) -> String {
"test".to_string()
7 changes: 2 additions & 5 deletions crates/core/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ use rustic_core::{
repofile::SnapshotFile, BackupOptions, ConfigOptions, InMemoryBackend, KeyOptions,
NoProgressBars, OpenStatus, PathList, Repository, RepositoryBackends, RepositoryOptions,
};
use simplelog::{Config, SimpleLogger};
use tar::Archive;
use tempfile::{tempdir, TempDir};

@@ -34,15 +33,13 @@ fn set_up_tar_fixture(path: impl AsRef<Path>) -> Result<TempDir> {

#[test]
fn simple_backup() -> Result<()> {
SimpleLogger::init(log::LevelFilter::Debug, Config::default())?;

let repo = set_up_repo()?.to_indexed_ids()?;
let opts = BackupOptions::default();
let dir = set_up_tar_fixture("backup-data.tar.gz")?;
let path = PathList::from_string(dir.path().to_str().unwrap())?;

// first backup
let snap1 = dbg!(repo.backup(&opts, &path, SnapshotFile::default())?);
let snap1 = repo.backup(&opts, &path, SnapshotFile::default())?;
assert_eq!(snap1.summary.as_ref().unwrap().files_new, 73);
assert_eq!(snap1.summary.as_ref().unwrap().dirs_new, 7);
assert_eq!(snap1.summary.as_ref().unwrap().files_unmodified, 0);
@@ -56,7 +53,7 @@ fn simple_backup() -> Result<()> {
// second backup
// re-read index
let repo = repo.to_indexed_ids()?;
let snap2 = dbg!(repo.backup(&opts, &path, SnapshotFile::default())?);
let snap2 = repo.backup(&opts, &path, SnapshotFile::default())?;
assert_eq!(snap2.summary.as_ref().unwrap().files_new, 0);
assert_eq!(snap2.summary.as_ref().unwrap().dirs_new, 0);
assert_eq!(snap2.summary.as_ref().unwrap().files_unmodified, 73);