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