Fix bug maj soft
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
"Bash(python git_updater.py)",
|
||||
"Bash(pip show:*)",
|
||||
"Bash(pip install:*)",
|
||||
"Bash(pyinstaller --onefile --windowed --name \"GitUpdateChecker\" git_updater.py)"
|
||||
"Bash(pyinstaller --onefile --windowed --name \"GitUpdateChecker\" git_updater.py)",
|
||||
"Bash(pyinstaller --onefile --console --name \"GitUpdateChecker\" --icon=NONE git_updater.py)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -135,6 +135,12 @@ def check_self_update():
|
||||
cwd=exe_dir,
|
||||
)
|
||||
count = len(log_out.splitlines()) if code == 0 and log_out else 0
|
||||
|
||||
if count == 0:
|
||||
# Hashes differents mais aucun commit a tirer (local en avance) -> pas de MAJ
|
||||
log.info("Auto-update: hashes differents mais 0 commit a tirer, skip")
|
||||
return False, ""
|
||||
|
||||
info = f"{count} commit(s) en retard sur origin/{branch}"
|
||||
log.info(f"Auto-update: MAJ disponible - {info}")
|
||||
return True, info
|
||||
@@ -170,23 +176,30 @@ def do_self_update():
|
||||
log.error(f"Auto-update: impossible de renommer l'exe: {e}")
|
||||
return False, f"Impossible de renommer l'exe: {e}"
|
||||
|
||||
# Restaurer les fichiers locaux modifiés puis pull
|
||||
run_git(["checkout", "--", "."], cwd=exe_dir)
|
||||
code, _, err = run_git(["pull", "origin", branch], cwd=exe_dir)
|
||||
# Pull avec fast-forward only (evite de toucher config.ini inutilement)
|
||||
code, _, err = run_git(["pull", "--ff-only", "origin", branch], cwd=exe_dir)
|
||||
|
||||
if code == 0:
|
||||
log.info("Auto-update: pull OK")
|
||||
return True, "Mise a jour reussie !\nLe programme va redemarrer."
|
||||
else:
|
||||
# En cas d'échec, restaurer l'ancien exe
|
||||
if is_frozen and exe_old_path and exe_old_path.exists():
|
||||
try:
|
||||
exe_old_path.rename(Path(sys.executable))
|
||||
log.info("Auto-update: exe restaure apres echec")
|
||||
except OSError:
|
||||
pass
|
||||
log.error(f"Auto-update: pull echoue: {err}")
|
||||
return False, f"Erreur pull: {err}"
|
||||
|
||||
# Si ff-only echoue (modifications locales), tenter reset hard sur origin
|
||||
log.warning(f"Auto-update: pull --ff-only echoue ({err}), tentative reset...")
|
||||
run_git(["reset", "--hard", f"origin/{branch}"], cwd=exe_dir)
|
||||
code2, _, err2 = run_git(["pull", "--ff-only", "origin", branch], cwd=exe_dir)
|
||||
if code2 == 0:
|
||||
log.info("Auto-update: reset + pull OK")
|
||||
return True, "Mise a jour reussie !\nLe programme va redemarrer."
|
||||
|
||||
# Echec definitif, restaurer l'ancien exe
|
||||
if is_frozen and exe_old_path and exe_old_path.exists():
|
||||
try:
|
||||
exe_old_path.rename(Path(sys.executable))
|
||||
log.info("Auto-update: exe restaure apres echec")
|
||||
except OSError:
|
||||
pass
|
||||
log.error(f"Auto-update: pull echoue: {err2}")
|
||||
return False, f"Erreur pull: {err2}"
|
||||
|
||||
|
||||
def relaunch_program():
|
||||
|
||||
Reference in New Issue
Block a user