No hangs, failure snow
This commit is contained in:
parent
ea40490b75
commit
fdccd87003
3 changed files with 9 additions and 7 deletions
|
@ -6,6 +6,8 @@ use failure::Fail;
|
||||||
pub enum BakareError {
|
pub enum BakareError {
|
||||||
#[fail(display = "io error")]
|
#[fail(display = "io error")]
|
||||||
IOError,
|
IOError,
|
||||||
|
#[fail(display = "unknown source path")]
|
||||||
|
UnknownSourcePathError,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::Error> for BakareError {
|
impl From<io::Error> for BakareError {
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl<'a> Iterator for RepositoryIterator<'a> {
|
||||||
type Item = RepositoryItem<'a>;
|
type Item = RepositoryItem<'a>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.current_item_number >= self.index.items.len() - 1 {
|
if self.index.items.is_empty() || self.current_item_number >= self.index.items.len() - 1 {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let current_item_number = self.current_item_number;
|
let current_item_number = self.current_item_number;
|
||||||
|
@ -81,9 +81,7 @@ impl<'a> Repository<'a> {
|
||||||
if source_path.is_dir() {
|
if source_path.is_dir() {
|
||||||
fs::create_dir(destination_path.clone())?;
|
fs::create_dir(destination_path.clone())?;
|
||||||
}
|
}
|
||||||
if source_path.is_file() {
|
if source_path.is_file() {}
|
||||||
fs::copy(source_path, destination_path.clone())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO create new version, remember source_path
|
// TODO create new version, remember source_path
|
||||||
|
|
||||||
|
@ -91,10 +89,10 @@ impl<'a> Repository<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item(&self, path: &Path) -> Option<RepositoryItem> {
|
pub fn item(&self, path: &Path) -> Option<RepositoryItem> {
|
||||||
unimplemented!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn newest_version_for(&self, source_path: &Path) -> Result<ItemVersion, BakareError> {
|
pub fn newest_version_for(&self, source_path: &Path) -> Result<ItemVersion, BakareError> {
|
||||||
unimplemented!()
|
Err(BakareError::UnknownSourcePathError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@ fn restore_older_version_of_file() -> Result<(), BakareError> {
|
||||||
|
|
||||||
source.write_text_to_file(relative_path_text, old_contents)?;
|
source.write_text_to_file(relative_path_text, old_contents)?;
|
||||||
backup_engine.backup()?;
|
backup_engine.backup()?;
|
||||||
let file_id = repository.item(&file_path).unwrap();
|
let file_id = repository.item(&file_path);
|
||||||
|
assert!(file_id.is_some());
|
||||||
|
let file_id = file_id.unwrap();
|
||||||
let old_version = file_id.version();
|
let old_version = file_id.version();
|
||||||
|
|
||||||
source.write_text_to_file(relative_path_text, new_contents)?;
|
source.write_text_to_file(relative_path_text, new_contents)?;
|
||||||
|
|
Loading…
Reference in a new issue