summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-01-05 14:31:23 +0200
committerLars Wirzenius <liw@liw.fi>2021-01-05 14:31:23 +0200
commitc2f7b5af1b9a237c740c71b3b65a155a8440cf3a (patch)
treef2db3d57cbd6db1e68779907f1477dca315220c5 /src/cmd
parentfee70c974049560164d8950dabc63554f55671b1 (diff)
downloadobnam2-c2f7b5af1b9a237c740c71b3b65a155a8440cf3a.tar.gz
refactor: add BackedUpFile to avoid using a tuple
The struct is easier to use right.
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/list_files.rs7
-rw-r--r--src/cmd/restore.rs10
2 files changed, 9 insertions, 8 deletions
diff --git a/src/cmd/list_files.rs b/src/cmd/list_files.rs
index aa4bed0..a69c3df 100644
--- a/src/cmd/list_files.rs
+++ b/src/cmd/list_files.rs
@@ -1,3 +1,4 @@
+use crate::backup_reason::Reason;
use crate::client::BackupClient;
use crate::client::ClientConfig;
use crate::error::ObnamError;
@@ -22,8 +23,8 @@ pub fn list_files(config: &ClientConfig, gen_ref: &str) -> anyhow::Result<()> {
};
let gen = client.fetch_generation(&gen_id, &dbname)?;
- for (_, entry, reason) in gen.files()? {
- println!("{}", format_entry(&entry, &reason));
+ for file in gen.files()? {
+ println!("{}", format_entry(&file.entry(), file.reason()));
}
// Delete the temporary file.
@@ -32,7 +33,7 @@ pub fn list_files(config: &ClientConfig, gen_ref: &str) -> anyhow::Result<()> {
Ok(())
}
-fn format_entry(e: &FilesystemEntry, reason: &str) -> String {
+fn format_entry(e: &FilesystemEntry, reason: Reason) -> String {
let kind = match e.kind() {
FilesystemKind::Regular => "-",
FilesystemKind::Directory => "d",
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs
index 0efdffb..c882e21 100644
--- a/src/cmd/restore.rs
+++ b/src/cmd/restore.rs
@@ -35,12 +35,12 @@ pub fn restore(config: &ClientConfig, gen_ref: &str, to: &Path) -> anyhow::Resul
let gen = client.fetch_generation(&gen_id, &dbname)?;
info!("restore file count: {}", gen.file_count()?);
let progress = create_progress_bar(gen.file_count()?, true);
- for (fileid, entry, _) in gen.files()? {
- restore_generation(&client, &gen, fileid, &entry, &to, &progress)?;
+ for file in gen.files()? {
+ restore_generation(&client, &gen, file.fileno(), file.entry(), &to, &progress)?;
}
- for (_, entry, _) in gen.files()? {
- if entry.is_dir() {
- restore_directory_metadata(&entry, &to)?;
+ for file in gen.files()? {
+ if file.entry().is_dir() {
+ restore_directory_metadata(file.entry(), &to)?;
}
}
progress.finish();