update aborted fix

This commit is contained in:
Louis Mazin 2025-09-09 17:57:35 +02:00
parent 9f94357acf
commit 890c6ff6ba

View File

@ -104,7 +104,11 @@ class UpdateManager:
for chunk in resp.iter_content(chunk_size=8192):
QApplication.processEvents()
if download_cancelled:
break
f.truncate(0)
f.close()
os.remove(local_path, dir_fd=None)
self.alert_manager.show_info(self.language_manager.get_text("update_aborted"), parent=parent)
return False
if chunk:
f.write(chunk)
@ -114,21 +118,10 @@ class UpdateManager:
dialog.close()
# Gérer l'annulation après la fermeture du fichier
if download_cancelled:
try:
if os.path.exists(local_path):
os.remove(local_path, dir_fd=None)
except (OSError, PermissionError):
# Si on ne peut pas supprimer le fichier, on continue sans erreur
pass
self.alert_manager.show_info(self.language_manager.get_text("update_aborted"), parent=parent)
return False
# Téléchargement réussi
msg = self.language_manager.get_text("update_downloaded").replace("{local_path}", local_path)
self.alert_manager.show_success(msg, parent=parent)
# Ouvre le fichier téléchargé
if sys.platform.startswith("win"):
os.startfile(local_path)
else:
@ -136,7 +129,6 @@ class UpdateManager:
subprocess.Popen([local_path])
return True
except Exception as e:
print(e)
self.alert_manager.show_error("update_download_error", parent=parent)
return False
@ -147,7 +139,6 @@ class UpdateManager:
latest_release = releases[0]
message = self.language_manager.get_text("update_found").replace("{latest_tag}", latest_release["tag_name"])
# Utiliser l'alert_manager avec boutons personnalisés
choice = self.alert_manager.show_choice_with_details(
message,
parent=parent,