use super::chunk_stat::*;
use super::chunk_store::*;
-use super::{IndexFile, ChunkReadInfo};
+use super::{ChunkReadInfo, IndexFile};
use crate::tools;
use std::fs::File;
pub fn open(path: &Path) -> Result<Self, Error> {
File::open(path)
.map_err(Error::from)
- .and_then(|file| Self::new(file))
+ .and_then(Self::new)
.map_err(|err| format_err!("Unable to open fixed index {:?} - {}", path, err))
}
let header_size = std::mem::size_of::<FixedIndexHeader>();
- let rawfd = file.as_raw_fd();
- let stat = match nix::sys::stat::fstat(rawfd) {
+ let stat = match nix::sys::stat::fstat(file.as_raw_fd()) {
Ok(stat) => stat,
Err(err) => bail!("fstat failed - {}", err),
};
let index_length = ((size + chunk_size - 1) / chunk_size) as usize;
let index_size = index_length * 32;
-
let expected_index_size = (stat.st_size as usize) - header_size;
if index_size != expected_index_size {
bail!(
println!("ChunkSize: {}", self.chunk_size);
let mut ctime_str = self.ctime.to_string();
- if let Ok(s) = proxmox::tools::time::strftime_local("%c",self.ctime) {
+ if let Ok(s) = proxmox::tools::time::strftime_local("%c", self.ctime) {
ctime_str = s;
}
Some((
(offset / self.chunk_size as u64) as usize,
- offset & (self.chunk_size - 1) as u64 // fast modulo, valid for 2^x chunk_size
+ offset & (self.chunk_size - 1) as u64, // fast modulo, valid for 2^x chunk_size
))
}
}