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