This commit is contained in:
Dennis Schwerdel 2017-04-24 07:37:05 +02:00
parent 43e86f31de
commit c2bf23d8d7
5 changed files with 14 additions and 14 deletions

View File

@ -255,13 +255,13 @@ impl BundleDb {
let id = bundle.id(); let id = bundle.id();
let (folder, filename) = self.layout.local_bundle_path(&id, self.local_bundles.len()); let (folder, filename) = self.layout.local_bundle_path(&id, self.local_bundles.len());
try!(fs::create_dir_all(&folder).context(&folder as &Path)); try!(fs::create_dir_all(&folder).context(&folder as &Path));
let bundle = try!(bundle.copy_to(self.layout.base_path(), folder.join(filename))); let bundle = try!(bundle.copy_to(&self.layout.base_path(), folder.join(filename)));
self.local_bundles.insert(id, bundle); self.local_bundles.insert(id, bundle);
Ok(()) Ok(())
} }
pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> { pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> {
let mut bundle = try!(bundle.finish(self)); let mut bundle = try!(bundle.finish(&self));
if bundle.info.mode == BundleMode::Meta { if bundle.info.mode == BundleMode::Meta {
try!(self.copy_remote_bundle_to_cache(&bundle)) try!(self.copy_remote_bundle_to_cache(&bundle))
} }
@ -288,7 +288,7 @@ impl BundleDb {
} }
pub fn get_chunk_list(&self, bundle: &BundleId) -> Result<ChunkList, BundleDbError> { pub fn get_chunk_list(&self, bundle: &BundleId) -> Result<ChunkList, BundleDbError> {
let mut bundle = try!(self.get_stored_bundle(bundle).and_then(|stored| self.get_bundle(stored))); let mut bundle = try!(self.get_stored_bundle(bundle).and_then(|stored| self.get_bundle(&stored)));
Ok(try!(bundle.get_chunk_list()).clone()) Ok(try!(bundle.get_chunk_list()).clone())
} }

View File

@ -160,7 +160,7 @@ impl Repository {
if inode.file_type == FileType::Directory { if inode.file_type == FileType::Directory {
let path = path.join(inode.name); let path = path.join(inode.name);
for chunks in inode.children.unwrap().values() { for chunks in inode.children.unwrap().values() {
let inode = try!(self.get_inode(chunks)); let inode = try!(self.get_inode(&chunks));
queue.push_back((path.clone(), inode)); queue.push_back((path.clone(), inode));
} }
} }

View File

@ -201,7 +201,7 @@ impl Repository {
pub fn get_stream<W: Write>(&mut self, chunks: &[Chunk], w: &mut W) -> Result<(), RepositoryError> { pub fn get_stream<W: Write>(&mut self, chunks: &[Chunk], w: &mut W) -> Result<(), RepositoryError> {
for &(ref hash, len) in chunks { for &(ref hash, len) in chunks {
let data = try!(try!(self.get_chunk(*hash)).ok_or_else(|| IntegrityError::MissingChunk(*hash))); let data = try!(try!(self.get_chunk(*hash)).ok_or_else(|| IntegrityError::MissingChunk(hash.clone())));
debug_assert_eq!(data.len() as u32, len); debug_assert_eq!(data.len() as u32, len);
try!(w.write_all(&data)); try!(w.write_all(&data));
} }

View File

@ -97,7 +97,7 @@ impl Repository {
}, },
Some(FileData::ChunkedIndirect(ref chunks)) => { Some(FileData::ChunkedIndirect(ref chunks)) => {
if try!(self.check_chunks(checked, chunks, true)) { if try!(self.check_chunks(checked, chunks, true)) {
let chunk_data = try!(self.get_data(chunks)); let chunk_data = try!(self.get_data(&chunks));
let chunks = ChunkList::read_from(&chunk_data); let chunks = ChunkList::read_from(&chunk_data);
try!(self.check_chunks(checked, &chunks, true)); try!(self.check_chunks(checked, &chunks, true));
} }
@ -191,12 +191,12 @@ impl Repository {
try!(self.flush()); try!(self.flush());
backup.root = chunks; backup.root = chunks;
backup.modified = true; backup.modified = true;
try!(self.evacuate_broken_backup(name)); try!(self.evacuate_broken_backup(&name));
try!(self.save_backup(backup, name)); try!(self.save_backup(&backup, &name));
}, },
Err(err) => if repair { Err(err) => if repair {
warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err); warn!("The root of the backup {} has been corrupted\n\tcaused by: {}", name, err);
try!(self.evacuate_broken_backup(name)); try!(self.evacuate_broken_backup(&name));
} else { } else {
return Err(err) return Err(err)
} }
@ -213,7 +213,7 @@ impl Repository {
}; };
info!("Checking inode..."); info!("Checking inode...");
let mut checked = Bitmap::new(self.index.capacity()); let mut checked = Bitmap::new(self.index.capacity());
let mut inodes = try!(self.get_backup_path(backup, path)); let mut inodes = try!(self.get_backup_path(&backup, path));
let mut inode = inodes.pop().unwrap(); let mut inode = inodes.pop().unwrap();
let mut modified = false; let mut modified = false;
if let Err(err) = self.check_inode_contents(&inode, &mut checked) { if let Err(err) = self.check_inode_contents(&inode, &mut checked) {
@ -260,8 +260,8 @@ impl Repository {
try!(self.flush()); try!(self.flush());
backup.root = chunks; backup.root = chunks;
backup.modified = true; backup.modified = true;
try!(self.evacuate_broken_backup(name)); try!(self.evacuate_broken_backup(&name));
try!(self.save_backup(backup, name)); try!(self.save_backup(&backup, &name));
} }
Ok(()) Ok(())
} }

View File

@ -249,7 +249,7 @@ impl Inode {
#[inline] #[inline]
pub fn decode(data: &[u8]) -> Result<Self, InodeError> { pub fn decode(data: &[u8]) -> Result<Self, InodeError> {
Ok(try!(msgpack::decode(data))) Ok(try!(msgpack::decode(&data)))
} }
} }
@ -299,7 +299,7 @@ impl Repository {
if let Some(ref contents) = inode.data { if let Some(ref contents) = inode.data {
match *contents { match *contents {
FileData::Inline(ref data) => { FileData::Inline(ref data) => {
try!(file.write_all(data)); try!(file.write_all(&data));
}, },
FileData::ChunkedDirect(ref chunks) => { FileData::ChunkedDirect(ref chunks) => {
try!(self.get_stream(chunks, &mut file)); try!(self.get_stream(chunks, &mut file));