Skip to content

Commit c870bed

Browse files
mnriemCopilot
andcommitted
Fix reinstall durability and workflow cleanup warnings
Assisted-by: GitHub Copilot (model: MAI-Code-1-Flash, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent eb28ce2 commit c870bed

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/specify_cli/extensions/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def _fsync_directory(path: Path) -> None:
121121
"""Sync a directory when the platform supports it."""
122122
if not path.exists():
123123
return
124+
if os.name == "nt":
125+
return
124126
try:
125127
dir_fd = os.open(str(path), os.O_RDONLY | getattr(os, "O_DIRECTORY", 0))
126128
except (AttributeError, NotImplementedError):
@@ -1543,6 +1545,10 @@ def install_from_directory(
15431545
_fsync_fd(fd)
15441546
finally:
15451547
os.close(fd)
1548+
# Flush the staging directory metadata before publishing the
1549+
# completion marker so a crash cannot leave a visible marker with
1550+
# only a subset of staged files.
1551+
_fsync_directory(rescue_staging_dir)
15461552
# Write the completion marker only after every staged file is
15471553
# fully written so a retry trusts staging only when it is whole.
15481554
marker_fd = os.open(
@@ -1639,7 +1645,9 @@ def _restore_stranded_config_file(
16391645
# crash mid-cleanup cannot leave a staging dir that a retry would
16401646
# wrongly trust as a complete durable backup.
16411647
rescue_complete_marker.unlink(missing_ok=True)
1648+
_fsync_directory(rescue_staging_dir)
16421649
shutil.rmtree(rescue_staging_dir)
1650+
_fsync_directory(rescue_staging_dir.parent)
16431651

16441652
# Register commands with AI agents
16451653
registered_commands = {}

src/specify_cli/workflows/_commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,8 @@ def _validate_and_install_local(
16661666
except OSError as cleanup_exc:
16671667
console.print(
16681668
"[yellow]Warning:[/yellow] Could not remove temporary "
1669-
f"workflow download file: {_escape_markup(str(cleanup_exc))}"
1669+
f"workflow download file: {_escape_markup(str(cleanup_exc))} "
1670+
f"(path: {_escape_markup(str(tmp_path))})"
16701671
)
16711672
console.print(f"[red]Error:[/red] Failed to download workflow: {_escape_markup(str(exc))}")
16721673
raise typer.Exit(1)
@@ -1690,7 +1691,8 @@ def _validate_and_install_local(
16901691
except OSError as exc:
16911692
console.print(
16921693
"[yellow]Warning:[/yellow] Could not remove temporary "
1693-
f"workflow download file: {_escape_markup(str(exc))}"
1694+
f"workflow download file: {_escape_markup(str(exc))} "
1695+
f"(path: {_escape_markup(str(tmp_path))})"
16941696
)
16951697
return
16961698

0 commit comments

Comments
 (0)