From f90702f93072076f02abec99ace8f3d09fdd0d9a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 18:55:51 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20infra:=20`=5Fregen=5Ffile`=20does=20not?= =?UTF-8?q?=20restore=20stash=20if=20generator=20fails=20=E2=80=94=20compo?= =?UTF-8?q?se=20file=20lost=20at=20temp=20path=20(#784)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/disinto | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/disinto b/bin/disinto index 43fa35d..b16a7ed 100755 --- a/bin/disinto +++ b/bin/disinto @@ -1545,8 +1545,14 @@ _regen_file() { mv "$target" "$stashed" fi - # Run the generator — it writes $target from scratch - "$generator" "$@" + # Run the generator — it writes $target from scratch. + # If the generator fails, restore the stashed original so it is not stranded. + if ! "$generator" "$@"; then + if [ -n "$stashed" ]; then + mv "$stashed" "$target" + fi + return 1 + fi if [ -z "$stashed" ]; then # No previous file — first generation