introduce different item and index versions
This commit is contained in:
parent
1d57ce9a89
commit
1335d04894
4 changed files with 24 additions and 14 deletions
|
@ -9,7 +9,7 @@ use walkdir::WalkDir;
|
||||||
|
|
||||||
use crate::error::BakareError;
|
use crate::error::BakareError;
|
||||||
use crate::repository::Repository;
|
use crate::repository::Repository;
|
||||||
use crate::Version;
|
use crate::ItemVersion;
|
||||||
|
|
||||||
pub struct Engine<'a> {
|
pub struct Engine<'a> {
|
||||||
source_path: &'a Path,
|
source_path: &'a Path,
|
||||||
|
|
|
@ -12,7 +12,9 @@ pub mod source;
|
||||||
|
|
||||||
pub mod repository;
|
pub mod repository;
|
||||||
|
|
||||||
pub struct Version(String);
|
pub struct ItemVersion(String);
|
||||||
|
|
||||||
struct Index {
|
pub struct IndexVersion;
|
||||||
|
struct IndexViewReadonly {
|
||||||
|
index_version: IndexVersion
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,30 @@ use std::path::Path;
|
||||||
use walkdir::DirEntry;
|
use walkdir::DirEntry;
|
||||||
|
|
||||||
use crate::error::BakareError;
|
use crate::error::BakareError;
|
||||||
use crate::Version;
|
use crate::ItemVersion;
|
||||||
use crate::Index;
|
use crate::IndexViewReadonly;
|
||||||
|
use crate::IndexVersion;
|
||||||
|
|
||||||
/// represents a place where backup is stored an can be restored from.
|
/// represents a place where backup is stored an can be restored from.
|
||||||
/// right now only on-disk directory storage is supported
|
/// right now only on-disk directory storage is supported
|
||||||
|
/// repository always knows the newest version of the index and is responsible for syncing the index to disk
|
||||||
|
/// and making sure that different threads can access index in parallel
|
||||||
pub struct Repository<'a> {
|
pub struct Repository<'a> {
|
||||||
/// absolute path to where the repository is stored on disk
|
/// absolute path to where the repository is stored on disk
|
||||||
path: &'a Path,
|
path: &'a Path,
|
||||||
index: Index
|
index: IndexViewReadonly,
|
||||||
|
newest_index_version: IndexVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RepositoryItem {
|
pub struct RepositoryItem {
|
||||||
version: Version
|
version: ItemVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RepositoryIterator;
|
|
||||||
|
pub struct RepositoryIterator {
|
||||||
|
version: IndexVersion,
|
||||||
|
index: IndexViewReadonly
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for RepositoryIterator {
|
impl<'a> Iterator for RepositoryIterator {
|
||||||
type Item = RepositoryItem;
|
type Item = RepositoryItem;
|
||||||
|
@ -32,7 +40,7 @@ impl<'a> Iterator for RepositoryIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RepositoryItem {
|
impl RepositoryItem {
|
||||||
pub fn version(&self) -> &Version {
|
pub fn version(&self) -> &ItemVersion {
|
||||||
&self.version
|
&self.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +49,11 @@ impl<'a> Repository<'a> {
|
||||||
pub fn open(path: &Path) -> Result<Repository, BakareError> {
|
pub fn open(path: &Path) -> Result<Repository, BakareError> {
|
||||||
// TODO open index from file
|
// TODO open index from file
|
||||||
|
|
||||||
Ok(Repository { path, index: Index {} })
|
Ok(Repository { path, index: IndexViewReadonly {} })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> RepositoryIterator {
|
pub fn iter(&self) -> RepositoryIterator {
|
||||||
unimplemented!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn store(&self, source_path: &Path) -> Result<(), BakareError> {
|
pub fn store(&self, source_path: &Path) -> Result<(), BakareError> {
|
||||||
|
@ -70,7 +78,7 @@ impl<'a> Repository<'a> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn newest_version_for(&self, source_path: &Path) -> Result<Version, BakareError> {
|
pub fn newest_version_for(&self, source_path: &Path) -> Result<ItemVersion, BakareError> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use walkdir::WalkDir;
|
||||||
|
|
||||||
use crate::error::BakareError;
|
use crate::error::BakareError;
|
||||||
use crate::repository::Repository;
|
use crate::repository::Repository;
|
||||||
use crate::Version;
|
use crate::ItemVersion;
|
||||||
use crate::repository::RepositoryItem;
|
use crate::repository::RepositoryItem;
|
||||||
|
|
||||||
pub struct Engine<'a> {
|
pub struct Engine<'a> {
|
||||||
|
@ -32,7 +32,7 @@ impl<'a> Engine<'a> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn restore_as_of_version(&self, item: &RepositoryItem, version: &Version) -> Result<(), BakareError> {
|
pub fn restore_as_of_version(&self, item: &RepositoryItem, version: &ItemVersion) -> Result<(), BakareError> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue