feat: don't read non-contributing archives for export
parent
b924a054a6
commit
6cdc18742e
|
@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased](https://git.rustybever.be/Chewing_Bever/alex/src/branch/dev)
|
## [Unreleased](https://git.rustybever.be/Chewing_Bever/alex/src/branch/dev)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Export command no longer reads backups that do not contribute to the final
|
||||||
|
state
|
||||||
|
|
||||||
## [0.3.1](https://git.rustybever.be/Chewing_Bever/alex/src/tag/0.3.1)
|
## [0.3.1](https://git.rustybever.be/Chewing_Bever/alex/src/tag/0.3.1)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -18,11 +18,18 @@ pub struct Delta {
|
||||||
impl Delta {
|
impl Delta {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
added: Default::default(),
|
added: State::new(),
|
||||||
removed: Default::default(),
|
removed: State::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the delta is empty by checking whether both its added and removed state
|
||||||
|
/// return true for their `is_empty`.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.added.is_empty() && self.removed.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
/// Calculate the union of this delta with another delta.
|
/// Calculate the union of this delta with another delta.
|
||||||
///
|
///
|
||||||
/// The union of two deltas is a delta that produces the same state as if you were to apply
|
/// The union of two deltas is a delta that produces the same state as if you were to apply
|
||||||
|
|
|
@ -226,9 +226,16 @@ where
|
||||||
let enc = GzEncoder::new(tar_gz, Compression::default());
|
let enc = GzEncoder::new(tar_gz, Compression::default());
|
||||||
let mut ar = tar::Builder::new(enc);
|
let mut ar = tar::Builder::new(enc);
|
||||||
|
|
||||||
for (contribution, backup) in
|
// We only need to consider backups that have a non-empty contribution.
|
||||||
contributions.iter().rev().zip(chain.iter().take(index + 1))
|
// This allows us to skip reading backups that have been completely
|
||||||
|
// overwritten by their successors anyways.
|
||||||
|
for (contribution, backup) in contributions
|
||||||
|
.iter()
|
||||||
|
.rev()
|
||||||
|
.zip(chain.iter().take(index + 1))
|
||||||
|
.filter(|(contribution, _)| !contribution.is_empty())
|
||||||
{
|
{
|
||||||
|
println!("{}", &backup);
|
||||||
backup.append(&self.backup_dir, contribution, &mut ar)?;
|
backup.append(&self.backup_dir, contribution, &mut ar)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,14 @@ impl State {
|
||||||
path.starts_with(dir) && files.contains(path.strip_prefix(dir).unwrap())
|
path.starts_with(dir) && files.contains(path.strip_prefix(dir).unwrap())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the state is empty.
|
||||||
|
///
|
||||||
|
/// Note that this does not necessarily mean that the state does not contain any sets, but
|
||||||
|
/// rather that any sets that it does contain are also empty.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.0.values().all(|s| s.is_empty())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<T> for State
|
impl<T> From<T> for State
|
||||||
|
|
Loading…
Reference in New Issue