Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #73 - handle NotFound error to delete index anyway if .litt dir… #77

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions litt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,17 @@ fn main() -> Result<(), LittError> {
Err(e) => return Err(LittError::General(e.to_string())),
};
let index_path = path.join(LITT_DIRECTORY_NAME);
fs::remove_dir_all(index_path).expect("Could not remove index-file");
let msg = match fs::remove_dir_all(index_path) {
//. expect("Could not remove index-file")
Ok(()) => "Ok.",
Err(e) if e.kind() == io::ErrorKind::NotFound => "Index directory didn't exist.",
Err(e) => return Err(LittError::General(e.to_string())),
};
// remove litt-index from tracker.
if let Err(e) = index_tracker.remove(index_name.clone()) {
return Err(LittError::General(e.to_string()));
}
println!("Deleted index \"{}\".", index_name);
println!("Deleted index \"{}\": {}", index_name, msg);
return Ok(());
}

Expand Down
Loading