fix: installer stops the service reliably before upgrading and retries locked file copies; 1.1.5

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
gti
2026-09-24 09:46:00 -03:00
co-authored by Claude Sonnet 5
parent e40e9500a4
commit 71bbf3e0bd
20 changed files with 44 additions and 27 deletions
+10 -3
View File
@@ -26,6 +26,7 @@ import os
import shutil
import sys
import threading
import time
import tkinter as tk
from pathlib import Path
from tkinter import filedialog, messagebox, ttk
@@ -141,8 +142,7 @@ def upgrade_flow(*, install_dir_path: str | None = None, progress: Callable[[str
version = setup_version()
progress("Atualizando o Agent (identidade e credenciais preservadas)…")
if common.service_installed():
common.stop_service()
common.wait_service_state("STOPPED", timeout=45)
common.ensure_service_stopped()
extract_payload(install)
common.upgrade_agent_env(install, version)
common.install_service(install)
@@ -175,7 +175,14 @@ def extract_payload(install: Path) -> None:
if not source.exists():
raise RuntimeError(f"bundled payload missing: {source}")
if source.is_dir():
shutil.copytree(source, dest, dirs_exist_ok=True)
for attempt in range(5): # a just-stopped host can still hold files for a moment
try:
shutil.copytree(source, dest, dirs_exist_ok=True)
break
except PermissionError:
if attempt == 4:
raise
time.sleep(3)
else:
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, dest)