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 {
|
||||
#[fail(display = "io error")]
|
||||
IOError,
|
||||
#[fail(display = "unknown source path")]
|
||||
UnknownSourcePathError,
|
||||
}
|
||||
|
||||
impl From<io::Error> for BakareError {
|
||||
|
|
|
@ -32,7 +32,7 @@ impl<'a> Iterator for RepositoryIterator<'a> {
|
|||
type Item = RepositoryItem<'a>;
|
||||
|
||||
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
|
||||
} else {
|
||||
let current_item_number = self.current_item_number;
|
||||
|
@ -81,9 +81,7 @@ impl<'a> Repository<'a> {
|
|||
if source_path.is_dir() {
|
||||
fs::create_dir(destination_path.clone())?;
|
||||
}
|
||||
if source_path.is_file() {
|
||||
fs::copy(source_path, destination_path.clone())?;
|
||||
}
|
||||
if source_path.is_file() {}
|
||||
|
||||
// TODO create new version, remember source_path
|
||||
|
||||
|
@ -91,10 +89,10 @@ impl<'a> Repository<'a> {
|
|||
}
|
||||
|
||||
pub fn item(&self, path: &Path) -> Option<RepositoryItem> {
|
||||
unimplemented!()
|
||||
None
|
||||
}
|
||||
|
||||
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)?;
|
||||
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();
|
||||
|
||||
source.write_text_to_file(relative_path_text, new_contents)?;
|
||||
|
|
Loading…
Reference in a new issue