Merge pull request #703 from rustic-rs/refactor-prune

move prune into rustic_core
This commit is contained in:
aawsome 2023-06-24 06:30:17 +02:00 committed by GitHub
commit be4022ed0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1172 additions and 1126 deletions

View File

@ -1,3 +1,4 @@
pub mod cat;
pub mod check;
pub mod prune;
pub mod repoinfo;

File diff suppressed because it is too large Load Diff

View File

@ -144,6 +144,24 @@ pub enum RusticErrorKind {
pub enum CommandErrorKind {
/// path is no dir: `{0:?}`
PathIsNoDir(String),
/// used blobs are missing: blob {0} doesn't existing
BlobsMissing(Id),
/// packs_to_delete doesn't contain `time`.
NoTimeInPacksToDelete,
/// used pack {0}: size does not match! Expected size: {1}, real size: {2}
PackSizeNotMatching(Id, u32, u32),
/// "used pack {0} does not exist!
PackNotExisting(Id),
/// pack {0} got no decicion what to do
NoDecicion(Id),
/// {0:?}
FromParseIntError(#[from] ParseIntError),
/// {0}
FromByteSizeParser(String),
/// --repack-uncompressed makes no sense for v1 repo!
RepackUncompressedRepoV1,
/// datetime out of range: `{0:?}`
FromOutOfRangeError(#[from] OutOfRangeError),
}
/// [`CryptoErrorKind`] describes the errors that can happen while dealing with Cryptographic functions

View File

@ -122,6 +122,7 @@ pub use crate::{
chunker::random_poly,
commands::{
check::CheckOpts,
prune::{PruneOpts, PrunePlan, PruneStats},
repoinfo::{BlobInfo, IndexInfos, PackInfo, RepoFileInfo, RepoFileInfos},
},
crypto::{aespoly1305::Key, hasher::hash},

View File

@ -36,7 +36,8 @@ use crate::{
crypto::aespoly1305::Key,
error::RepositoryErrorKind,
repofile::{configfile::ConfigFile, keyfile::find_key_in_backend},
BlobType, IndexBackend, NoProgressBars, ProgressBars, RusticResult, SnapshotFile,
BlobType, IndexBackend, NoProgressBars, ProgressBars, PruneOpts, PrunePlan, RusticResult,
SnapshotFile,
};
pub(super) mod constants {
@ -380,6 +381,10 @@ impl<P: ProgressBars> OpenRepository<P> {
opts.run(self)
}
pub fn prune_plan(&self, opts: &PruneOpts) -> RusticResult<PrunePlan> {
opts.get_plan(self)
}
pub fn to_indexed(self) -> RusticResult<IndexedRepository<P>> {
let index = IndexBackend::new(&self.dbe, &self.pb.progress_counter(""))?;
Ok(IndexedRepository { repo: self, index })

View File

@ -201,7 +201,7 @@ impl ForgetCmd {
if self.config.prune {
let mut prune_opts = self.prune_opts.clone();
prune_opts.ignore_snaps = forget_snaps;
prune_opts.opts.ignore_snaps = forget_snaps;
prune_opts.run();
}

File diff suppressed because it is too large Load Diff