diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2021-07-28 19:50:03 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2021-07-28 23:02:24 +0300 |
commit | 3a1e5f10dd8aef4bc02f76e735c4a3244147ffe8 (patch) | |
tree | a30cd5ca8b498b9c9cca8ce95c7a0833dce8abb2 /src/backup_run.rs | |
parent | 97938e694da84f20d39f6895c50cd29b89cc7dd5 (diff) | |
download | obnam2-3a1e5f10dd8aef4bc02f76e735c4a3244147ffe8.tar.gz |
FsIter: annotate entries belonging to CACHEDIR.TAGs
Diffstat (limited to 'src/backup_run.rs')
-rw-r--r-- | src/backup_run.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs index 9667382..2b23aa4 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -5,7 +5,7 @@ use crate::client::{BackupClient, ClientError}; use crate::config::ClientConfig; use crate::error::ObnamError; use crate::fsentry::FilesystemEntry; -use crate::fsiter::{FsIterError, FsIterator}; +use crate::fsiter::{AnnotatedFsEntry, FsIterError, FsIterator}; use crate::generation::{LocalGeneration, LocalGenerationError, NascentError, NascentGeneration}; use crate::policy::BackupPolicy; use log::{info, warn}; @@ -119,7 +119,7 @@ impl<'a> BackupRun<'a> { pub fn backup( &self, - entry: Result<FilesystemEntry, FsIterError>, + entry: Result<AnnotatedFsEntry, FsIterError>, old: &LocalGeneration, ) -> Result<FsEntryBackupOutcome, BackupError> { match entry { @@ -129,10 +129,10 @@ impl<'a> BackupRun<'a> { Err(BackupError::FsIterError(err)) } Ok(entry) => { - let path = &entry.pathbuf(); + let path = &entry.inner.pathbuf(); info!("backup: {}", path.display()); self.found_live_file(path); - let reason = self.policy.needs_backup(&old, &entry); + let reason = self.policy.needs_backup(&old, &entry.inner); match reason { Reason::IsNew | Reason::Changed @@ -145,7 +145,7 @@ impl<'a> BackupRun<'a> { reason, )), Reason::Unchanged | Reason::Skipped | Reason::FileError => { - let fileno = old.get_fileno(&entry.pathbuf())?; + let fileno = old.get_fileno(&entry.inner.pathbuf())?; let ids = if let Some(fileno) = fileno { let mut ids = vec![]; for id in old.chunkids(fileno)?.iter()? { @@ -155,12 +155,11 @@ impl<'a> BackupRun<'a> { } else { vec![] }; - // TODO: replace `false` with an actual value Ok(FsEntryBackupOutcome { - entry, + entry: entry.inner, ids, reason, - is_cachedir_tag: false, + is_cachedir_tag: entry.is_cachedir_tag, }) } } @@ -179,29 +178,27 @@ impl<'a> BackupRun<'a> { fn backup_file( client: &BackupClient, - entry: &FilesystemEntry, + entry: &AnnotatedFsEntry, path: &Path, chunk_size: usize, reason: Reason, ) -> FsEntryBackupOutcome { - let ids = client.upload_filesystem_entry(&entry, chunk_size); + let ids = client.upload_filesystem_entry(&entry.inner, chunk_size); match ids { Err(err) => { warn!("error backing up {}, skipping it: {}", path.display(), err); FsEntryBackupOutcome { - entry: entry.clone(), + entry: entry.inner.clone(), ids: vec![], reason: Reason::FileError, - // TODO: replace `false` with an actual value - is_cachedir_tag: false, + is_cachedir_tag: entry.is_cachedir_tag, } } Ok(ids) => FsEntryBackupOutcome { - entry: entry.clone(), + entry: entry.inner.clone(), ids, reason, - // TODO: replace `false` with an actual value - is_cachedir_tag: false, + is_cachedir_tag: entry.is_cachedir_tag, }, } } |