Skip to content

Commit 10a7f91

Browse files
committed
Update 1 code files
Modified: • src/omnipkg/dispatcher.py (+5/-8 lines) [gitship-generated]
1 parent 4998417 commit 10a7f91

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/omnipkg/dispatcher.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -575,21 +575,18 @@ def _install_binary_into_bin_dir(binary_tmp, target_bin, src_hash: str, debug: b
575575
target_bin = Path(target_bin)
576576

577577
_exe = ".exe" if sys.platform == "win32" else ""
578-
all_succeeded = True # <-- NEW: Track if any replacements fail
578+
all_succeeded = True # <-- NEW: Track if all binaries successfully update
579579

580580
for name in ("8pkg", "omnipkg", "OMNIPKG", "8PKG"):
581581
target = target_bin / (name + _exe)
582582
if target.exists():
583583
try:
584-
# NEW: Windows running-executable overwrite trick
584+
# NEW: Windows file lock bypass: Rename the running executable first
585585
if sys.platform == "win32":
586586
old_target = target.with_name(target.name + ".old")
587587
try:
588588
if old_target.exists():
589589
old_target.unlink()
590-
except Exception:
591-
pass
592-
try:
593590
target.rename(old_target)
594591
except Exception:
595592
pass
@@ -599,11 +596,11 @@ def _install_binary_into_bin_dir(binary_tmp, target_bin, src_hash: str, debug: b
599596
os.chmod(str(target), 0o755)
600597
replaced.append(str(target))
601598
except Exception as e:
602-
all_succeeded = False # <-- Mark failure
599+
all_succeeded = False # <-- NEW: Mark as failed!
603600
if debug:
604601
print(f"[C-INSTALL] could not replace {target}: {e}", file=sys.stderr)
605602

606-
# NEW: Only write marker if ALL binaries were successfully replaced
603+
# NEW: ONLY write the marker if every replacement succeeded
607604
if replaced and all_succeeded and src_hash and c_src:
608605
try:
609606
(target_bin / ".omnipkg_dispatch_compiled").write_text(
@@ -1767,7 +1764,7 @@ def _ensure_all_version_shims(bin_dir: Path, debug_mode: bool = False) -> None:
17671764
try:
17681765
existing = bat_path.read_text(encoding="ascii")
17691766
# NEW: Check against \n version safely
1770-
if existing == bat_content or existing == bat_content.replace("\r\n", "\n"):
1767+
if existing.replace("\r\n", "\n") == bat_content.replace("\r\n", "\n"):
17711768
continue # already correct — truly idempotent
17721769

17731770
if debug_mode:

0 commit comments

Comments
 (0)