Clean up .tour on failed init

Aborting the metadata prompts (Ctrl-C/EOF) left a half-built .tour behind,
so every later `tour init` failed with TourAlreadyExists and no recovery.

Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
2026-09-22 22:16:16 +01:00
co-authored by Claude Code
parent 8c2d1df03f
commit 45da723d49
+6 -2
View File
@@ -17,8 +17,12 @@ pub fn init() -> Result<(), TourError> {
fs::File::create(tour_dir.join("session"))?; fs::File::create(tour_dir.join("session"))?;
crate::info::set_info()?; // A prompt aborted with Ctrl-C/EOF must not leave a half-built .tour behind,
update_gitignore()?; // which would make every later `tour init` fail with TourAlreadyExists.
if let Err(e) = crate::info::set_info().and_then(|_| update_gitignore()) {
let _ = fs::remove_dir_all(&tour_dir);
return Err(e.into());
}
Ok(()) Ok(())
} }