backup/chunk_store: make percentage output optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
d59397e60e
commit
eff25ecaf2
|
@ -191,6 +191,7 @@ impl ChunkStore {
|
|||
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
print_percentage: bool,
|
||||
) -> Result<
|
||||
impl Iterator<Item = Result<tools::fs::ReadDirEntry, Error>>,
|
||||
Error
|
||||
|
@ -210,11 +211,13 @@ impl ChunkStore {
|
|||
let mut last_percentage = 0;
|
||||
|
||||
Ok((0..0x10000).filter_map(move |index| {
|
||||
if print_percentage {
|
||||
let percentage = (index * 100) / 0x10000;
|
||||
if last_percentage != percentage {
|
||||
last_percentage = percentage;
|
||||
eprintln!("percentage done: {}", percentage);
|
||||
}
|
||||
}
|
||||
let subdir: &str = &format!("{:04x}", index);
|
||||
match tools::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
|
||||
Err(e) => {
|
||||
|
@ -252,7 +255,7 @@ impl ChunkStore {
|
|||
|
||||
let now = unsafe { libc::time(std::ptr::null_mut()) };
|
||||
|
||||
for entry in self.get_chunk_iterator()? {
|
||||
for entry in self.get_chunk_iterator(true)? {
|
||||
let (dirfd, entry) = match entry {
|
||||
Ok(entry) => (entry.parent_fd(), entry),
|
||||
Err(_) => continue, // ignore errors
|
||||
|
|
|
@ -86,11 +86,12 @@ impl DataStore {
|
|||
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
print_percentage: bool,
|
||||
) -> Result<
|
||||
impl Iterator<Item = Result<tools::fs::ReadDirEntry, Error>>,
|
||||
Error
|
||||
> {
|
||||
self.chunk_store.get_chunk_iterator()
|
||||
self.chunk_store.get_chunk_iterator(print_percentage)
|
||||
}
|
||||
|
||||
pub fn create_fixed_writer<P: AsRef<Path>>(&self, filename: P, size: usize, chunk_size: usize) -> Result<FixedIndexWriter, Error> {
|
||||
|
|
Loading…
Reference in New Issue