summaryrefslogtreecommitdiff
path: root/src/backup_run.rs
diff options
context:
space:
mode:
authorAlexander Batischev <eual.jp@gmail.com>2021-07-28 20:16:53 +0300
committerAlexander Batischev <eual.jp@gmail.com>2021-07-28 23:02:56 +0300
commit640f8d874d627489efe2f55333e1f9ae8120596b (patch)
tree7acbc86ea3cc6a4641a140af30f234baf9d3dd06 /src/backup_run.rs
parent3a1e5f10dd8aef4bc02f76e735c4a3244147ffe8 (diff)
downloadobnam2-640f8d874d627489efe2f55333e1f9ae8120596b.tar.gz
After the backup, print out a list of new CACHEDIR.TAGs
Diffstat (limited to 'src/backup_run.rs')
-rw-r--r--src/backup_run.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs
index 2b23aa4..b01b365 100644
--- a/src/backup_run.rs
+++ b/src/backup_run.rs
@@ -9,7 +9,7 @@ use crate::fsiter::{AnnotatedFsEntry, FsIterError, FsIterator};
use crate::generation::{LocalGeneration, LocalGenerationError, NascentError, NascentGeneration};
use crate::policy::BackupPolicy;
use log::{info, warn};
-use std::path::Path;
+use std::path::{Path, PathBuf};
pub struct BackupRun<'a> {
client: &'a BackupClient,
@@ -102,19 +102,30 @@ impl<'a> BackupRun<'a> {
config: &ClientConfig,
old: &LocalGeneration,
newpath: &Path,
- ) -> Result<(i64, Vec<BackupError>), NascentError> {
+ // TODO: turn this tuple into a struct for readability
+ ) -> Result<(i64, Vec<BackupError>, Vec<PathBuf>), NascentError> {
let mut all_warnings = vec![];
+ let mut new_cachedir_tags = vec![];
let count = {
let mut new = NascentGeneration::create(newpath)?;
for root in &config.roots {
let iter = FsIterator::new(root, config.exclude_cache_tag_directories);
- let mut warnings = new.insert_iter(iter.map(|entry| self.backup(entry, &old)))?;
+ let entries = iter.map(|entry| {
+ if let Ok(ref entry) = entry {
+ let path = entry.inner.pathbuf();
+ if entry.is_cachedir_tag && !old.is_cachedir_tag(&path)? {
+ new_cachedir_tags.push(path);
+ }
+ };
+ self.backup(entry, &old)
+ });
+ let mut warnings = new.insert_iter(entries)?;
all_warnings.append(&mut warnings);
}
new.file_count()
};
self.finish();
- Ok((count, all_warnings))
+ Ok((count, all_warnings, new_cachedir_tags))
}
pub fn backup(