Skip to content

Commit

Permalink
The --incomplete option is obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Jul 26, 2020
1 parent 2b874f9 commit acd753f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 58 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Expand Up @@ -8,6 +8,11 @@
This means that restoring from a backup that did not complete will give the
most complete available copy of the tree at that point in time.

### Behavior changes

- The `--incomplete` option, to read the partial tree from an interrupted
backup, is no longer needed and has been removed.

## v0.6.4 2020-07-04

### Features
Expand Down
49 changes: 9 additions & 40 deletions src/bin/conserve.rs
Expand Up @@ -53,9 +53,6 @@ enum Command {
backup: Option<BandId>,
#[structopt(long, short, number_of_values = 1)]
exclude: Vec<String>,
/// Compare to the incomplete contents of an unfinished backup.
#[structopt(long, requires = "backup")]
incomplete: bool,
},

/// Create a new archive.
Expand Down Expand Up @@ -84,9 +81,6 @@ enum Command {
exclude: Vec<String>,
#[structopt(long = "only", short = "i", number_of_values = 1)]
only_subtree: Option<Apath>,
/// Restore the incomplete contents of an unfinished backup.
#[structopt(long, requires = "backup")]
incomplete: bool,
},

/// Show the total size of files in a stored tree or source directory, with exclusions.
Expand Down Expand Up @@ -127,10 +121,6 @@ struct StoredTreeOrSource {

#[structopt(long, short, number_of_values = 1)]
exclude: Vec<String>,

/// Measure the incomplete contents of an unfinished backup.
#[structopt(long, requires = "backup")]
incomplete: bool,
}

/// Show debugging information.
Expand All @@ -144,10 +134,6 @@ enum Debug {
/// Backup version number.
#[structopt(long, short)]
backup: Option<BandId>,

/// List the incomplete contents of an unfinished backup.
#[structopt(long, requires = "backup")]
incomplete: bool,
},

/// List all blocks.
Expand Down Expand Up @@ -187,12 +173,8 @@ impl Command {
writeln!(bw, "{}", hash)?;
}
}
Command::Debug(Debug::Index {
archive,
backup,
incomplete,
}) => {
let st = stored_tree_from_opt(archive, &backup, &Vec::new(), *incomplete)?;
Command::Debug(Debug::Index { archive, backup }) => {
let st = stored_tree_from_opt(archive, &backup, &Vec::new())?;
output::show_index_json(&st.band(), &mut stdout)?;
}
Command::Debug(Debug::Referenced { archive }) => {
Expand All @@ -206,13 +188,12 @@ impl Command {
source,
backup,
exclude,
incomplete,
} => {
// TODO: Consider whether the actual files have changed.
// TODO: Summarize diff.
// TODO: Optionally include unchanged files.
let excludes = excludes::from_strings(exclude)?;
let st = stored_tree_from_opt(archive, backup, exclude, *incomplete)?;
let st = stored_tree_from_opt(archive, backup, exclude)?;
let lt = LiveTree::open(source)?.with_excludes(excludes);
output::show_tree_diff(&mut conserve::iter_merged_entries(&st, &lt)?, &mut stdout)?;
}
Expand All @@ -223,12 +204,7 @@ impl Command {
Command::Ls { stos } => {
if let Some(archive) = &stos.archive {
output::show_tree_names(
&stored_tree_from_opt(
archive,
&stos.backup,
&stos.exclude,
stos.incomplete,
)?,
&stored_tree_from_opt(archive, &stos.backup, &stos.exclude)?,
&mut stdout,
)?;
} else {
Expand All @@ -246,9 +222,8 @@ impl Command {
force_overwrite,
exclude,
only_subtree,
incomplete,
} => {
let band_selection = band_selection_policy_from_opt(backup, *incomplete);
let band_selection = band_selection_policy_from_opt(backup);
let archive = Archive::open_path(archive)?;

let options = RestoreOptions {
Expand All @@ -266,7 +241,7 @@ impl Command {
Command::Size { ref stos } => {
ui::set_progress_phase(&"Measuring".to_string());
let size = if let Some(archive) = &stos.archive {
stored_tree_from_opt(archive, &stos.backup, &stos.exclude, stos.incomplete)?
stored_tree_from_opt(archive, &stos.backup, &stos.exclude)?
.size()?
.file_bytes
} else {
Expand Down Expand Up @@ -305,25 +280,19 @@ fn stored_tree_from_opt(
archive: &Path,
backup: &Option<BandId>,
exclude: &[String],
incomplete: bool,
) -> Result<StoredTree> {
let archive = Archive::open_path(archive)?;
let policy = band_selection_policy_from_opt(backup, incomplete);
let policy = band_selection_policy_from_opt(backup);
Ok(archive
.open_stored_tree(policy)?
.with_excludes(excludes::from_strings(exclude)?))
}

fn band_selection_policy_from_opt(
backup: &Option<BandId>,
incomplete: bool,
) -> BandSelectionPolicy {
fn band_selection_policy_from_opt(backup: &Option<BandId>) -> BandSelectionPolicy {
if let Some(band_id) = backup {
BandSelectionPolicy::Specified(band_id.clone())
} else if incomplete {
BandSelectionPolicy::Latest
} else {
BandSelectionPolicy::LatestClosed
BandSelectionPolicy::Latest
}
}

Expand Down
21 changes: 3 additions & 18 deletions tests/blackbox.rs
Expand Up @@ -342,8 +342,7 @@ fn empty_archive() {

/// Check behavior on an incomplete version.
///
/// Commands that read from the archive should by default decline, unless given
/// `--incomplete`.
/// The `--incomplete` option is no longer needed.
#[test]
fn incomplete_version() {
let af = ScratchArchive::new();
Expand All @@ -358,22 +357,8 @@ fn incomplete_version() {
.stdout(predicate::str::contains("b0000"))
.stdout(predicate::str::contains("incomplete"));

// ls fails on incomplete band
run_conserve()
.arg("ls")
.arg(af.path())
.assert()
.failure()
.stdout(predicate::str::contains("Archive has no bands"));

// ls --incomplete accurately says it has nothing
run_conserve()
.args(&["ls", "-b", "b0", "--incomplete"])
.arg(af.path())
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::is_empty());
// ls succeeds on an incomplete band
run_conserve().arg("ls").arg(af.path()).assert().success();
}

#[test]
Expand Down

0 comments on commit acd753f

Please sign in to comment.