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(
|
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,11 +211,13 @@ 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| {
|
||||||
|
if print_percentage {
|
||||||
let percentage = (index * 100) / 0x10000;
|
let percentage = (index * 100) / 0x10000;
|
||||||
if last_percentage != percentage {
|
if last_percentage != percentage {
|
||||||
last_percentage = percentage;
|
last_percentage = percentage;
|
||||||
eprintln!("percentage done: {}", 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) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -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> {
|
||||||
|
Loading…
Reference in New Issue
Block a user