From 45da723d49251a52c548ccdc4d27b17eaf9d3796 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 22 Sep 2026 22:16:16 +0100 Subject: [PATCH] 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 --- src/init.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/init.rs b/src/init.rs index 00a4266..b0b16d9 100644 --- a/src/init.rs +++ b/src/init.rs @@ -17,8 +17,12 @@ pub fn init() -> Result<(), TourError> { fs::File::create(tour_dir.join("session"))?; - crate::info::set_info()?; - update_gitignore()?; + // A prompt aborted with Ctrl-C/EOF must not leave a half-built .tour behind, + // 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(()) }