mirror of https://github.com/dswd/zvault
contents -> data
This commit is contained in:
parent
f6862aa669
commit
014c456fd0
|
@ -106,8 +106,6 @@ Recommended: Brotli/2-7
|
|||
### Formats
|
||||
- Bundles
|
||||
- Encrypted bundle header
|
||||
- Metadata
|
||||
- Arbitrarily nested chunk lists
|
||||
|
||||
### CLI functionality
|
||||
- list --tree
|
||||
|
|
12
src/mount.rs
12
src/mount.rs
|
@ -262,12 +262,12 @@ impl<'a> FuseFilesystem<'a> {
|
|||
pub fn fetch_chunks(&mut self, inode: &FuseInodeRef) -> Result<(), RepositoryError> {
|
||||
let mut inode = inode.borrow_mut();
|
||||
let mut chunks = None;
|
||||
match inode.inode.contents {
|
||||
None | Some(FileContents::Inline(_)) => (),
|
||||
Some(FileContents::ChunkedDirect(ref c)) => {
|
||||
match inode.inode.data {
|
||||
None | Some(FileData::Inline(_)) => (),
|
||||
Some(FileData::ChunkedDirect(ref c)) => {
|
||||
chunks = Some(c.clone());
|
||||
},
|
||||
Some(FileContents::ChunkedIndirect(ref c)) => {
|
||||
Some(FileData::ChunkedIndirect(ref c)) => {
|
||||
let chunk_data = try!(self.repository.get_data(c));
|
||||
chunks = Some(ChunkList::read_from(&chunk_data));
|
||||
}
|
||||
|
@ -393,9 +393,9 @@ impl<'a> fuse::Filesystem for FuseFilesystem<'a> {
|
|||
info!("read {:?}, offset {}, size {}", ino, offset, size);
|
||||
let inode = inode!(self, ino, reply);
|
||||
let inode = inode.borrow();
|
||||
match inode.inode.contents {
|
||||
match inode.inode.data {
|
||||
None => return reply.data(&[]),
|
||||
Some(FileContents::Inline(ref data)) => return reply.data(&data[min(offset as usize, data.len())..min(offset as usize+size as usize, data.len())]),
|
||||
Some(FileData::Inline(ref data)) => return reply.data(&data[min(offset as usize, data.len())..min(offset as usize+size as usize, data.len())]),
|
||||
_ => ()
|
||||
}
|
||||
if let Some(ref chunks) = inode.chunks {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
pub use ::util::*;
|
||||
pub use ::bundledb::{BundleReader, BundleMode, BundleWriter, BundleInfo, BundleId, BundleDbError, BundleDb, BundleWriterError};
|
||||
pub use ::chunker::{ChunkerType, Chunker, ChunkerStatus, IChunker, ChunkerError};
|
||||
pub use ::repository::{Repository, Backup, Config, RepositoryError, RepositoryInfo, Inode, FileType, RepositoryIntegrityError, BackupFileError, BackupError, BackupOptions, BundleAnalysis, FileContents, DiffType};
|
||||
pub use ::repository::{Repository, Backup, Config, RepositoryError, RepositoryInfo, Inode, FileType, RepositoryIntegrityError, BackupFileError, BackupError, BackupOptions, BundleAnalysis, FileData, DiffType};
|
||||
pub use ::index::{Index, Location, IndexError};
|
||||
pub use ::mount::FuseFilesystem;
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ impl Repository {
|
|||
|
||||
#[inline]
|
||||
fn find_differences_recurse(&mut self, inode1: &Inode, inode2: &Inode, path: PathBuf, diffs: &mut Vec<(DiffType, PathBuf)>) -> Result<(), RepositoryError> {
|
||||
if !inode1.is_same_meta(inode2) || inode1.contents != inode2.contents {
|
||||
if !inode1.is_same_meta(inode2) || inode1.data != inode2.data {
|
||||
diffs.push((DiffType::Mod, path.clone()));
|
||||
}
|
||||
if let Some(ref children1) = inode1.children {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use ::prelude::*;
|
||||
|
||||
use super::metadata::FileContents;
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
|
||||
|
@ -83,12 +81,12 @@ impl Repository {
|
|||
}
|
||||
let inode = try!(self.get_inode(&chunks));
|
||||
// Mark the content chunks as used
|
||||
match inode.contents {
|
||||
None | Some(FileContents::Inline(_)) => (),
|
||||
Some(FileContents::ChunkedDirect(chunks)) => {
|
||||
match inode.data {
|
||||
None | Some(FileData::Inline(_)) => (),
|
||||
Some(FileData::ChunkedDirect(chunks)) => {
|
||||
try!(self.mark_used(&mut usage, &chunks));
|
||||
},
|
||||
Some(FileContents::ChunkedIndirect(chunks)) => {
|
||||
Some(FileData::ChunkedIndirect(chunks)) => {
|
||||
if try!(self.mark_used(&mut usage, &chunks)) {
|
||||
let chunk_data = try!(self.get_data(&chunks));
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use ::prelude::*;
|
||||
|
||||
use super::metadata::FileContents;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
|
||||
|
@ -76,18 +74,18 @@ impl Repository {
|
|||
}
|
||||
|
||||
fn check_inode_contents(&mut self, inode: &Inode, checked: &mut Bitmap) -> Result<(), RepositoryError> {
|
||||
match inode.contents {
|
||||
Some(FileContents::ChunkedDirect(ref chunks)) => {
|
||||
match inode.data {
|
||||
None | Some(FileData::Inline(_)) => (),
|
||||
Some(FileData::ChunkedDirect(ref chunks)) => {
|
||||
try!(self.check_chunks(checked, chunks));
|
||||
},
|
||||
Some(FileContents::ChunkedIndirect(ref chunks)) => {
|
||||
Some(FileData::ChunkedIndirect(ref chunks)) => {
|
||||
if try!(self.check_chunks(checked, chunks)) {
|
||||
let chunk_data = try!(self.get_data(&chunks));
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
try!(self.check_chunks(checked, &chunks));
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -91,12 +91,12 @@ impl fmt::Display for FileType {
|
|||
|
||||
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
pub enum FileContents {
|
||||
pub enum FileData {
|
||||
Inline(msgpack::Bytes),
|
||||
ChunkedDirect(ChunkList),
|
||||
ChunkedIndirect(ChunkList)
|
||||
}
|
||||
serde_impl!(FileContents(u8) {
|
||||
serde_impl!(FileData(u8) {
|
||||
Inline(ByteBuf) => 0,
|
||||
ChunkedDirect(ChunkList) => 1,
|
||||
ChunkedIndirect(ChunkList) => 2
|
||||
|
@ -113,7 +113,7 @@ pub struct Inode {
|
|||
pub group: u32,
|
||||
pub timestamp: i64,
|
||||
pub symlink_target: Option<String>,
|
||||
pub contents: Option<FileContents>,
|
||||
pub data: Option<FileData>,
|
||||
pub children: Option<BTreeMap<String, ChunkList>>,
|
||||
pub cum_size: u64,
|
||||
pub cum_dirs: usize,
|
||||
|
@ -130,7 +130,7 @@ impl Default for Inode {
|
|||
group: 1000,
|
||||
timestamp: 0,
|
||||
symlink_target: None,
|
||||
contents: None,
|
||||
data: None,
|
||||
children: None,
|
||||
cum_size: 0,
|
||||
cum_dirs: 0,
|
||||
|
@ -149,7 +149,7 @@ serde_impl!(Inode(u8?) {
|
|||
timestamp: i64 => 7,
|
||||
//__old_create_time: i64 => 8,
|
||||
symlink_target: Option<String> => 9,
|
||||
contents: Option<FileContents> => 10,
|
||||
data: Option<FileData> => 10,
|
||||
children: BTreeMap<String, ChunkList> => 11,
|
||||
cum_size: u64 => 12,
|
||||
cum_dirs: usize => 13,
|
||||
|
@ -245,7 +245,7 @@ impl Repository {
|
|||
if inode.file_type == FileType::File && inode.size > 0 {
|
||||
if let Some(reference) = reference {
|
||||
if reference.is_same_meta_quick(&inode) {
|
||||
inode.contents = reference.contents.clone();
|
||||
inode.data = reference.data.clone();
|
||||
return Ok(inode)
|
||||
}
|
||||
}
|
||||
|
@ -253,16 +253,16 @@ impl Repository {
|
|||
if inode.size < 100 {
|
||||
let mut data = Vec::with_capacity(inode.size as usize);
|
||||
try!(file.read_to_end(&mut data));
|
||||
inode.contents = Some(FileContents::Inline(data.into()));
|
||||
inode.data = Some(FileData::Inline(data.into()));
|
||||
} else {
|
||||
let mut chunks = try!(self.put_stream(BundleMode::Content, &mut file));
|
||||
if chunks.len() < 10 {
|
||||
inode.contents = Some(FileContents::ChunkedDirect(chunks));
|
||||
inode.data = Some(FileData::ChunkedDirect(chunks));
|
||||
} else {
|
||||
let mut chunk_data = Vec::with_capacity(chunks.encoded_size());
|
||||
chunks.write_to(&mut chunk_data).unwrap();
|
||||
chunks = try!(self.put_data(BundleMode::Meta, &chunk_data));
|
||||
inode.contents = Some(FileContents::ChunkedIndirect(chunks));
|
||||
inode.data = Some(FileData::ChunkedIndirect(chunks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,15 +282,15 @@ impl Repository {
|
|||
#[inline]
|
||||
pub fn save_inode_at<P: AsRef<Path>>(&mut self, inode: &Inode, path: P) -> Result<(), RepositoryError> {
|
||||
if let Some(mut file) = try!(inode.create_at(path.as_ref())) {
|
||||
if let Some(ref contents) = inode.contents {
|
||||
if let Some(ref contents) = inode.data {
|
||||
match *contents {
|
||||
FileContents::Inline(ref data) => {
|
||||
FileData::Inline(ref data) => {
|
||||
try!(file.write_all(&data));
|
||||
},
|
||||
FileContents::ChunkedDirect(ref chunks) => {
|
||||
FileData::ChunkedDirect(ref chunks) => {
|
||||
try!(self.get_stream(chunks, &mut file));
|
||||
},
|
||||
FileContents::ChunkedIndirect(ref chunks) => {
|
||||
FileData::ChunkedIndirect(ref chunks) => {
|
||||
let chunk_data = try!(self.get_data(chunks));
|
||||
let chunks = ChunkList::read_from(&chunk_data);
|
||||
try!(self.get_stream(&chunks, &mut file));
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::io::Write;
|
|||
|
||||
pub use self::error::RepositoryError;
|
||||
pub use self::config::Config;
|
||||
pub use self::metadata::{Inode, FileType, FileContents};
|
||||
pub use self::metadata::{Inode, FileType, FileData};
|
||||
pub use self::backup::{BackupError, BackupOptions, DiffType};
|
||||
pub use self::backup_file::{Backup, BackupFileError};
|
||||
pub use self::integrity::RepositoryIntegrityError;
|
||||
|
|
Loading…
Reference in New Issue