mirror of
https://github.com/Dummi26/rembackup.git
synced 2025-03-10 05:13:54 +01:00
fix bug which would show all directories in change list, even unchanged ones
This commit is contained in:
parent
209821820b
commit
3d9f3365ba
@ -65,15 +65,18 @@ pub fn perform_index_diff<'a>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (total_size, changes) = rec(
|
if let Some((total_size, changes)) = rec(
|
||||||
source.as_ref(),
|
source.as_ref(),
|
||||||
Path::new(""),
|
Path::new(""),
|
||||||
index,
|
index,
|
||||||
&ignore,
|
&ignore,
|
||||||
settings,
|
settings,
|
||||||
sort_by_size_largest,
|
sort_by_size_largest,
|
||||||
)?;
|
)? {
|
||||||
Ok((total_size, changes))
|
Ok((total_size, changes))
|
||||||
|
} else {
|
||||||
|
Ok((0, vec![]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn rec(
|
fn rec(
|
||||||
// location of source files
|
// location of source files
|
||||||
@ -85,7 +88,7 @@ fn rec(
|
|||||||
ignore: &Ignore,
|
ignore: &Ignore,
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
sort_by_size_largest: Option<bool>,
|
sort_by_size_largest: Option<bool>,
|
||||||
) -> Result<(u64, Vec<IndexChange>), (String, PathBuf, io::Error)> {
|
) -> Result<Option<(u64, Vec<IndexChange>)>, (String, PathBuf, io::Error)> {
|
||||||
let mut removals = vec![];
|
let mut removals = vec![];
|
||||||
let mut ichanges = vec![];
|
let mut ichanges = vec![];
|
||||||
let mut total_size = 0;
|
let mut total_size = 0;
|
||||||
@ -141,16 +144,17 @@ fn rec(
|
|||||||
// is dir, but was file -> remove file
|
// is dir, but was file -> remove file
|
||||||
removals.push(IndexChange::RemoveFile(rel_path.clone()));
|
removals.push(IndexChange::RemoveFile(rel_path.clone()));
|
||||||
}
|
}
|
||||||
let (rec_size, rec_changes) = rec(
|
if let Some((rec_size, rec_changes)) = rec(
|
||||||
source,
|
source,
|
||||||
&rel_path,
|
&rel_path,
|
||||||
index_files,
|
index_files,
|
||||||
ignore,
|
ignore,
|
||||||
settings,
|
settings,
|
||||||
sort_by_size_largest,
|
sort_by_size_largest,
|
||||||
)?;
|
)? {
|
||||||
total_size += rec_size;
|
total_size += rec_size;
|
||||||
ichanges.push((rec_size, rec_changes));
|
ichanges.push((rec_size, rec_changes));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(true) = in_index_and_is_dir {
|
if let Some(true) = in_index_and_is_dir {
|
||||||
// is file, but was dir -> remove dir
|
// is file, but was dir -> remove dir
|
||||||
@ -184,6 +188,9 @@ fn rec(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// combine everything
|
// combine everything
|
||||||
|
if !dir_is_new && removals.is_empty() && ichanges.is_empty() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
let changes = [IndexChange::AddDir(
|
let changes = [IndexChange::AddDir(
|
||||||
rel_path.to_path_buf(),
|
rel_path.to_path_buf(),
|
||||||
dir_is_new,
|
dir_is_new,
|
||||||
@ -193,5 +200,5 @@ fn rec(
|
|||||||
.chain(removals.into_iter())
|
.chain(removals.into_iter())
|
||||||
.chain(ichanges.into_iter().flat_map(|(_, v)| v))
|
.chain(ichanges.into_iter().flat_map(|(_, v)| v))
|
||||||
.collect();
|
.collect();
|
||||||
Ok((total_size, changes))
|
Ok(Some((total_size, changes)))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user