summaryrefslogtreecommitdiff
path: root/src/backup_run.rs
diff options
context:
space:
mode:
authorAlexander Batischev <eual.jp@gmail.com>2021-07-21 21:26:05 +0300
committerAlexander Batischev <eual.jp@gmail.com>2021-07-21 22:25:47 +0300
commit24a3284979e41405e213f031ccfcca3f6f1513eb (patch)
tree240ae29c62be7a4bf2abdb53c1b0fc2214514216 /src/backup_run.rs
parent90e8f2dbf2f87a6a8fef8d44801642d9c644050f (diff)
downloadobnam2-24a3284979e41405e213f031ccfcca3f6f1513eb.tar.gz
backup_run: replace tuple with a struct
Diffstat (limited to 'src/backup_run.rs')
-rw-r--r--src/backup_run.rs26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs
index ccbf640..6c3a4f2 100644
--- a/src/backup_run.rs
+++ b/src/backup_run.rs
@@ -30,6 +30,13 @@ pub enum BackupError {
LocalGenerationError(#[from] LocalGenerationError),
}
+#[derive(Debug)]
+pub struct FsEntryBackupOutcome {
+ pub entry: FilesystemEntry,
+ pub ids: Vec<ChunkId>,
+ pub reason: Reason,
+}
+
impl<'a> BackupRun<'a> {
pub fn initial(config: &ClientConfig, client: &'a BackupClient) -> Result<Self, BackupError> {
Ok(Self {
@@ -108,11 +115,12 @@ impl<'a> BackupRun<'a> {
self.finish();
Ok((count, all_warnings))
}
+
pub fn backup(
&self,
entry: FsIterResult<FilesystemEntry>,
old: &LocalGeneration,
- ) -> Result<(FilesystemEntry, Vec<ChunkId>, Reason), BackupError> {
+ ) -> Result<FsEntryBackupOutcome, BackupError> {
match entry {
Err(err) => {
warn!("backup: {}", err);
@@ -146,7 +154,7 @@ impl<'a> BackupRun<'a> {
} else {
vec![]
};
- Ok((entry, ids, reason))
+ Ok(FsEntryBackupOutcome { entry, ids, reason })
}
}
}
@@ -168,13 +176,21 @@ fn backup_file(
path: &Path,
chunk_size: usize,
reason: Reason,
-) -> (FilesystemEntry, Vec<ChunkId>, Reason) {
+) -> FsEntryBackupOutcome {
let ids = client.upload_filesystem_entry(&entry, chunk_size);
match ids {
Err(err) => {
warn!("error backing up {}, skipping it: {}", path.display(), err);
- (entry.clone(), vec![], Reason::FileError)
+ FsEntryBackupOutcome {
+ entry: entry.clone(),
+ ids: vec![],
+ reason: Reason::FileError,
+ }
}
- Ok(ids) => (entry.clone(), ids, reason),
+ Ok(ids) => FsEntryBackupOutcome {
+ entry: entry.clone(),
+ ids,
+ reason,
+ },
}
}