mirror of https://github.com/dswd/zvault
Removed some public fields
This commit is contained in:
parent
048a48873a
commit
4287896945
|
@ -77,11 +77,11 @@ impl BackupRepository {
|
|||
}
|
||||
|
||||
pub fn get_config(&self) -> &Config {
|
||||
&self.repo.config
|
||||
self.repo.get_config()
|
||||
}
|
||||
|
||||
pub fn set_config(&mut self, config: Config) {
|
||||
self.repo.config = config;
|
||||
self.repo.set_config(config);
|
||||
}
|
||||
|
||||
pub fn get_layout(&self) -> &RepositoryLayout {
|
||||
|
|
|
@ -117,7 +117,7 @@ fn load_bundles(
|
|||
|
||||
|
||||
pub struct BundleDb {
|
||||
pub layout: Arc<ChunkRepositoryLayout>,
|
||||
layout: Arc<ChunkRepositoryLayout>,
|
||||
uploader: Option<Arc<BundleUploader>>,
|
||||
crypto: Arc<Crypto>,
|
||||
local_bundles: HashMap<BundleId, StoredBundle>,
|
||||
|
@ -284,6 +284,7 @@ impl BundleDb {
|
|||
encryption: Option<Encryption>,
|
||||
) -> Result<BundleWriter, BundleDbError> {
|
||||
Ok(try!(BundleWriter::new(
|
||||
self.layout.clone(),
|
||||
mode,
|
||||
hash_method,
|
||||
compression,
|
||||
|
@ -346,7 +347,7 @@ impl BundleDb {
|
|||
}
|
||||
|
||||
pub fn add_bundle(&mut self, bundle: BundleWriter) -> Result<BundleInfo, BundleDbError> {
|
||||
let mut bundle = try!(bundle.finish(self));
|
||||
let mut bundle = try!(bundle.finish());
|
||||
if bundle.info.mode == BundleMode::Meta {
|
||||
try!(self.copy_remote_bundle_to_cache(&bundle))
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ quick_error!{
|
|||
|
||||
|
||||
pub struct BundleWriter {
|
||||
layout: Arc<ChunkRepositoryLayout>,
|
||||
mode: BundleMode,
|
||||
hash_method: HashMethod,
|
||||
data: Vec<u8>,
|
||||
|
@ -59,6 +60,7 @@ pub struct BundleWriter {
|
|||
|
||||
impl BundleWriter {
|
||||
pub fn new(
|
||||
layout: Arc<ChunkRepositoryLayout>,
|
||||
mode: BundleMode,
|
||||
hash_method: HashMethod,
|
||||
compression: Option<Compression>,
|
||||
|
@ -72,6 +74,7 @@ impl BundleWriter {
|
|||
None => None,
|
||||
};
|
||||
Ok(BundleWriter {
|
||||
layout,
|
||||
mode,
|
||||
hash_method,
|
||||
data: vec![],
|
||||
|
@ -99,7 +102,7 @@ impl BundleWriter {
|
|||
Ok(self.chunk_count - 1)
|
||||
}
|
||||
|
||||
pub fn finish(mut self, db: &BundleDb) -> Result<StoredBundle, BundleWriterError> {
|
||||
pub fn finish(mut self) -> Result<StoredBundle, BundleWriterError> {
|
||||
if let Some(stream) = self.compression_stream {
|
||||
try!(stream.finish(&mut self.data).map_err(
|
||||
BundleWriterError::Compression
|
||||
|
@ -115,7 +118,7 @@ impl BundleWriter {
|
|||
if let Some(ref encryption) = self.encryption {
|
||||
chunk_data = try!(self.crypto.encrypt(encryption, &chunk_data));
|
||||
}
|
||||
let mut path = db.layout.temp_bundle_path();
|
||||
let mut path = self.layout.temp_bundle_path();
|
||||
let mut file = BufWriter::new(try!(File::create(&path).context(&path as &Path)));
|
||||
try!(file.write_all(&HEADER_STRING).context(&path as &Path));
|
||||
try!(file.write_all(&[HEADER_VERSION]).context(&path as &Path));
|
||||
|
@ -145,7 +148,7 @@ impl BundleWriter {
|
|||
try!(file.write_all(&info_data).context(&path as &Path));
|
||||
try!(file.write_all(&chunk_data).context(&path as &Path));
|
||||
try!(file.write_all(&self.data).context(&path as &Path));
|
||||
path = path.strip_prefix(db.layout.base_path())
|
||||
path = path.strip_prefix(self.layout.base_path())
|
||||
.unwrap()
|
||||
.to_path_buf();
|
||||
Ok(StoredBundle {
|
||||
|
|
|
@ -75,7 +75,7 @@ impl index::Key for Hash {
|
|||
|
||||
pub struct Repository {
|
||||
layout: Arc<ChunkRepositoryLayout>,
|
||||
pub config: Config,
|
||||
config: Config,
|
||||
index: Index<Hash, Location>,
|
||||
crypto: Arc<Crypto>,
|
||||
bundle_map: BundleMap,
|
||||
|
@ -399,6 +399,14 @@ impl Repository {
|
|||
pub fn set_clean(&mut self) {
|
||||
self.dirty = false;
|
||||
}
|
||||
|
||||
pub fn get_config(&self) -> &Config {
|
||||
&self.config
|
||||
}
|
||||
|
||||
pub fn set_config(&mut self, config: Config) {
|
||||
self.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue