Skip to content

Commit

Permalink
Manual rebase V
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsan committed Aug 17, 2023
1 parent ada0b2e commit a68e938
Show file tree
Hide file tree
Showing 14 changed files with 1,316 additions and 136 deletions.
47 changes: 47 additions & 0 deletions crates/rustic_core/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,49 @@ use crate::{
repofile::{configfile::ConfigFile, snapshotfile::SnapshotFile},
Progress, RusticResult,
};

/// The `Archiver` is responsible for archiving files and trees.
/// It will read the file, chunk it, and write the chunks to the backend.
///
/// # Type Parameters
///
/// * `BE` - The backend type.
/// * `I` - The index to read from.
#[allow(missing_debug_implementations)]
pub struct Archiver<BE: DecryptWriteBackend, I: IndexedBackend> {
/// The `FileArchiver` is responsible for archiving files.
file_archiver: FileArchiver<BE, I>,

/// The `TreeArchiver` is responsible for archiving trees.
tree_archiver: TreeArchiver<BE, I>,

/// The parent snapshot to use.
parent: Parent,

/// The SharedIndexer is used to index the data.
indexer: SharedIndexer<BE>,

/// The backend to write to.
be: BE,

/// The SnapshotFile to write to.
snap: SnapshotFile,
}

impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
/// Creates a new `Archiver`.
///
/// # Arguments
///
/// * `be` - The backend to write to.
/// * `index` - The index to read from.
/// * `config` - The config file.
/// * `parent` - The parent snapshot to use.
/// * `snap` - The `SnapshotFile` to write to.
///
/// # Errors
///
/// If we can't create the `FileArchiver` or `TreeArchiver`.
pub fn new(
be: BE,
index: I,
Expand All @@ -54,6 +86,21 @@ impl<BE: DecryptWriteBackend, I: IndexedBackend> Archiver<BE, I> {
})
}

/// Archives the given source.
///
/// This will archive all files and trees in the given source.
///
/// # Type Parameters
///
/// * `R` - The type of the source.
///
/// # Arguments
///
/// * `index` - The index to read from.
/// * `src` - The source to archive.
/// * `backup_path` - The path to the backup.
/// * `as_path` - The path to archive the backup as.
/// * `p` - The progress bar.
pub fn archive<R>(
mut self,
index: &I,
Expand Down
Loading

0 comments on commit a68e938

Please sign in to comment.