Sync from development - prepare for v0.1.2

This commit is contained in:
Omni
2025-09-18 10:41:16 +01:00
parent 64c76046ce
commit 28cde64887
2 changed files with 76 additions and 24 deletions

View File

@@ -103,15 +103,33 @@ class UpdateService:
# Determine if this is a delta update # Determine if this is a delta update
is_delta = '.delta' in download_url or 'delta' in download_url.lower() is_delta = '.delta' in download_url or 'delta' in download_url.lower()
return UpdateInfo( # Safety checks to prevent segfault
version=latest_version, try:
tag_name=release_data['tag_name'], # Sanitize string fields
release_date=release_data['published_at'], safe_version = str(latest_version) if latest_version else ""
changelog=release_data.get('body', ''), safe_tag = str(release_data.get('tag_name', ''))
download_url=download_url, safe_date = str(release_data.get('published_at', ''))
safe_changelog = str(release_data.get('body', ''))[:1000] # Limit size
safe_url = str(download_url)
logger.debug(f"Creating UpdateInfo for version {safe_version}")
update_info = UpdateInfo(
version=safe_version,
tag_name=safe_tag,
release_date=safe_date,
changelog=safe_changelog,
download_url=safe_url,
file_size=file_size, file_size=file_size,
is_delta_update=is_delta is_delta_update=is_delta
) )
logger.debug(f"UpdateInfo created successfully")
return update_info
except Exception as e:
logger.error(f"Failed to create UpdateInfo: {e}")
return None
else: else:
logger.warning(f"No AppImage found in release {latest_version}") logger.warning(f"No AppImage found in release {latest_version}")
@@ -173,9 +191,14 @@ class UpdateService:
def check_worker(): def check_worker():
try: try:
update_info = self.check_for_updates() update_info = self.check_for_updates()
logger.debug(f"check_worker: Received update_info: {update_info}")
logger.debug(f"check_worker: About to call callback...")
callback(update_info) callback(update_info)
logger.debug(f"check_worker: Callback completed")
except Exception as e: except Exception as e:
logger.error(f"Error in background update check: {e}") logger.error(f"Error in background update check: {e}")
import traceback
logger.error(f"Traceback: {traceback.format_exc()}")
callback(None) callback(None)
thread = threading.Thread(target=check_worker, daemon=True) thread = threading.Thread(target=check_worker, daemon=True)

View File

@@ -801,26 +801,55 @@ class JackifyMainWindow(QMainWindow):
# Continue anyway - don't block startup on detection errors # Continue anyway - don't block startup on detection errors
def _check_for_updates_on_startup(self): def _check_for_updates_on_startup(self):
"""Check for updates on startup in background thread""" """Check for updates on startup - SIMPLE VERSION"""
try: try:
debug_print("Checking for updates on startup...") debug_print("Checking for updates on startup...")
def update_check_callback(update_info): # Do it synchronously and simply
"""Handle update check results""" update_info = self.update_service.check_for_updates()
try:
if update_info: if update_info:
debug_print(f"Update available: v{update_info.version}") debug_print(f"Update available: v{update_info.version}")
# Show update dialog
# Simple QMessageBox - no complex dialogs
from PySide6.QtWidgets import QMessageBox
from PySide6.QtCore import QTimer
def show_update_dialog():
try:
debug_print("Creating UpdateDialog...")
from jackify.frontends.gui.dialogs.update_dialog import UpdateDialog from jackify.frontends.gui.dialogs.update_dialog import UpdateDialog
dialog = UpdateDialog(update_info, self.update_service, self) dialog = UpdateDialog(update_info, self.update_service, self)
debug_print("UpdateDialog created, showing...")
dialog.show() # Non-blocking dialog.show() # Non-blocking
debug_print("UpdateDialog shown successfully")
except Exception as e:
debug_print(f"UpdateDialog failed: {e}, falling back to simple dialog")
# Fallback to simple dialog
reply = QMessageBox.question(
self,
"Update Available",
f"Jackify v{update_info.version} is available.\n\nDownload and install now?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.Yes
)
if reply == QMessageBox.Yes:
# Simple download and replace
try:
new_appimage = self.update_service.download_update(update_info)
if new_appimage:
if self.update_service.apply_update(new_appimage):
debug_print("Update applied successfully")
else:
QMessageBox.warning(self, "Update Failed", "Failed to apply update.")
else:
QMessageBox.warning(self, "Update Failed", "Failed to download update.")
except Exception as e:
QMessageBox.warning(self, "Update Failed", f"Update failed: {e}")
# Use QTimer to show dialog after GUI is fully loaded
QTimer.singleShot(1000, show_update_dialog)
else: else:
debug_print("No updates available") debug_print("No updates available")
except Exception as e:
debug_print(f"Error showing update dialog: {e}")
# Check for updates in background
self.update_service.check_for_updates_async(update_check_callback)
except Exception as e: except Exception as e:
debug_print(f"Error checking for updates on startup: {e}") debug_print(f"Error checking for updates on startup: {e}")