mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
fix(workflows): catch OSError in per-workflow update loop and make restore best-effort
Transient FS errors (perms, disk full) from backup read or write no longer abort the whole update run. The restore is wrapped in its own try/except so a failed write only warns, and the offending workflow is reported via 'Failed to update' like other per-workflow failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1096,10 +1096,21 @@ def workflow_update(
|
||||
wf_file = wf_dir / "workflow.yml"
|
||||
backup = wf_file.read_bytes() if wf_file.is_file() else None
|
||||
_install_workflow_from_catalog(project_root, registry, workflows_dir, update["id"])
|
||||
except typer.Exit:
|
||||
except (typer.Exit, OSError) as exc:
|
||||
if backup is not None and wf_dir is not None and wf_file is not None:
|
||||
wf_dir.mkdir(parents=True, exist_ok=True)
|
||||
wf_file.write_bytes(backup)
|
||||
try:
|
||||
wf_dir.mkdir(parents=True, exist_ok=True)
|
||||
wf_file.write_bytes(backup)
|
||||
except OSError as restore_exc:
|
||||
console.print(
|
||||
f"[yellow]Warning:[/yellow] Could not restore backup for "
|
||||
f"'{_escape_markup(update['id'])}': {_escape_markup(str(restore_exc))}"
|
||||
)
|
||||
if isinstance(exc, OSError):
|
||||
console.print(
|
||||
f"[red]Error:[/red] Filesystem error updating "
|
||||
f"'{_escape_markup(update['id'])}': {_escape_markup(str(exc))}"
|
||||
)
|
||||
failed.append(update["id"])
|
||||
|
||||
if failed:
|
||||
|
||||
Reference in New Issue
Block a user