fixup more install/remove issues with system mode
This commit is contained in:
parent
faf4985067
commit
c34442241c
2 changed files with 32 additions and 25 deletions
|
|
@ -469,13 +469,13 @@ class AppstreamSearcher:
|
|||
# Process categories one at a time to keep GUI responsive
|
||||
for category, title in categories.items():
|
||||
if "installed" in category:
|
||||
installed_apps = searcher.get_installed_apps()
|
||||
installed_apps = searcher.get_installed_apps(system)
|
||||
for app_id, repo_name, repo_type in installed_apps:
|
||||
if repo_name:
|
||||
search_result = searcher.search_flatpak(app_id, repo_name)
|
||||
self.installed_results.extend(search_result)
|
||||
elif "updates" in category:
|
||||
updates = searcher.check_updates()
|
||||
updates = searcher.check_updates(system)
|
||||
for repo_name, app_id, repo_type in updates:
|
||||
if repo_name:
|
||||
search_result = searcher.search_flatpak(app_id, repo_name)
|
||||
|
|
@ -641,9 +641,9 @@ def install_flatpak(app: AppStreamPackage, repo_name=None, system=False) -> tupl
|
|||
# Run the transaction
|
||||
try:
|
||||
transaction.run()
|
||||
return True, f"Successfully installed {app.id}"
|
||||
except GLib.Error as e:
|
||||
return False, f"Installation failed: {e}"
|
||||
return True, f"Successfully installed {app.id}"
|
||||
|
||||
def remove_flatpak(app: AppStreamPackage, repo_name=None, system=False) -> tuple[bool, str]:
|
||||
"""
|
||||
|
|
@ -661,21 +661,16 @@ def remove_flatpak(app: AppStreamPackage, repo_name=None, system=False) -> tuple
|
|||
|
||||
# Get the appropriate installation based on user parameter
|
||||
installation = get_installation(system)
|
||||
searcher = get_reposearcher(system)
|
||||
|
||||
installed_apps = searcher.get_installed_apps()
|
||||
for ins_app_id_bundle, ins_repo_name, ins_repo_type in installed_apps:
|
||||
if ins_app_id_bundle == app.flatpak_bundle:
|
||||
# Create a new transaction for removal
|
||||
transaction = Flatpak.Transaction.new_for_installation(installation)
|
||||
transaction.add_uninstall(ins_app_id_bundle)
|
||||
# Run the transaction
|
||||
try:
|
||||
transaction.run()
|
||||
return True, f"Successfully removed {app.id}"
|
||||
except GLib.Error as e:
|
||||
return False, f"Failed to remove {app.id}: {e}"
|
||||
return False, f"Application '{app.id}' is not installed."
|
||||
# Create a new transaction for removal
|
||||
transaction = Flatpak.Transaction.new_for_installation(installation)
|
||||
transaction.add_uninstall(app.flatpak_bundle)
|
||||
# Run the transaction
|
||||
try:
|
||||
transaction.run()
|
||||
except GLib.Error as e:
|
||||
return False, f"Failed to remove {app.id}: {e}"
|
||||
return True, f"Successfully removed {app.id}"
|
||||
|
||||
|
||||
def get_installation(system=False):
|
||||
|
|
@ -952,21 +947,29 @@ def handle_remove_repo(args):
|
|||
|
||||
def handle_install(args, searcher):
|
||||
packagelist = searcher.search_flatpak(args.install, args.repo)
|
||||
result_message = ""
|
||||
for package in packagelist:
|
||||
try:
|
||||
success, message = install_flatpak(package, args.repo, args.system)
|
||||
print(f"{message}")
|
||||
result_message = f"{message}"
|
||||
break
|
||||
except GLib.Error as e:
|
||||
print(f"{str(e)}")
|
||||
result_message = f"Installation of {args.install} failed: {str(e)}"
|
||||
pass
|
||||
print(result_message)
|
||||
|
||||
def handle_remove(args, searcher):
|
||||
packagelist = searcher.search_flatpak(args.remove, args.repo)
|
||||
result_message = ""
|
||||
for package in packagelist:
|
||||
try:
|
||||
success, message = remove_flatpak(package, args.repo, args.system)
|
||||
print(f"{message}")
|
||||
result_message = f"{message}"
|
||||
break
|
||||
except GLib.Error as e:
|
||||
print(f"{str(e)}")
|
||||
result_message = f"Installation of {args.install} failed: {str(e)}"
|
||||
pass
|
||||
print(result_message)
|
||||
|
||||
def handle_list_installed(args, searcher):
|
||||
installed_apps = searcher.get_installed_apps(args.system)
|
||||
|
|
|
|||
12
main.py
12
main.py
|
|
@ -253,6 +253,10 @@ class MainWindow(Gtk.Window):
|
|||
self.system_mode = False
|
||||
self.refresh_data()
|
||||
self.refresh_current_page()
|
||||
elif self.system_mode == False:
|
||||
self.system_mode = True
|
||||
self.refresh_data()
|
||||
self.refresh_current_page()
|
||||
|
||||
def populate_repo_dropdown(self):
|
||||
# Get list of repositories
|
||||
|
|
@ -1061,7 +1065,6 @@ class MainWindow(Gtk.Window):
|
|||
thread = threading.Thread(target=perform_installation)
|
||||
thread.daemon = True # Allow program to exit even if thread is still running
|
||||
thread.start()
|
||||
|
||||
dialog.destroy()
|
||||
|
||||
def on_task_complete(self, dialog, success, message):
|
||||
|
|
@ -1079,12 +1082,13 @@ class MainWindow(Gtk.Window):
|
|||
buttons=Gtk.ButtonsType.OK,
|
||||
text=message
|
||||
)
|
||||
self.refresh_local()
|
||||
self.refresh_current_page()
|
||||
finished_dialog.run()
|
||||
finished_dialog.destroy()
|
||||
self.refresh_local()
|
||||
self.refresh_current_page()
|
||||
self.waiting_dialog.destroy()
|
||||
|
||||
|
||||
def on_remove_clicked(self, button, app):
|
||||
"""Handle the Remove button click with removal options"""
|
||||
details = app.get_details()
|
||||
|
|
@ -1118,7 +1122,7 @@ class MainWindow(Gtk.Window):
|
|||
# Show waiting dialog
|
||||
GLib.idle_add(self.show_waiting_dialog, "Removing package...")
|
||||
|
||||
success, message = libflatpak_query.remove_flatpak(app, self.system_mode)
|
||||
success, message = libflatpak_query.remove_flatpak(app, None, self.system_mode)
|
||||
|
||||
# Update UI on main thread
|
||||
GLib.idle_add(lambda: self.on_task_complete(dialog, success, message))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue