diff --git a/CHANGELOG.md b/CHANGELOG.md index a08a39f4..a08d781d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - UI - the "Skip" button on the initialization panel is now enabled after 10 seconds [#310](https://github.com/vinifmor/bauh/issues/310) +### Fixes +- AppImage + - upgrade fails when the package was initially imported, but later added to bauh's database [#321](https://github.com/vinifmor/bauh/issues/321) + ### Contributions - German translations by [Mape6](https://github.com/Mape6) diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index b25d0995..bcad21ab 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -122,7 +122,7 @@ class AppImageManager(SoftwareManager, SettingsController): else: return False - appim = AppImage(i18n=self.i18n, imported=True) + appim = AppImage(i18n=self.i18n, imported=True, manual_update=True) appim.name = input_name.get_value().strip() appim.local_file_path = file_chooser.file_path appim.version = input_version.get_value() @@ -168,6 +168,7 @@ class AppImageManager(SoftwareManager, SettingsController): pkg.local_file_path = file_chooser.file_path pkg.version = input_version.get_value() + pkg.manual_update = True reqs = UpgradeRequirements(to_install=None, to_remove=None, to_upgrade=[UpgradeRequirement(pkg=pkg)], cannot_upgrade=None) return self.upgrade(reqs, root_password=root_password, watcher=watcher) @@ -368,6 +369,16 @@ class AppImageManager(SoftwareManager, SettingsController): download_data = None + # always changing the 'imported' field based on the 'manual_update' flag that means + # "the user is manually installing/updating the AppImage" + if not req.pkg.manual_update: + req.pkg.imported = False + + if req.pkg.categories and "Imported" in req.pkg.categories: + # removing the imported category in case the file is not considered imported anymore + req.pkg.categories.remove("Imported") + + # manual file updates do not required download it if not req.pkg.imported: download_data = self._download(req.pkg, watcher) @@ -593,8 +604,8 @@ class AppImageManager(SoftwareManager, SettingsController): Path(out_dir).mkdir(parents=True, exist_ok=True) pkg.install_dir = out_dir - if pkg.imported: - + # when the package is being imported/upgraded there is no need to download it + if pkg.manual_update: downloaded, file_name = True, pkg.local_file_path.split('/')[-1] install_file_path = out_dir + '/' + file_name diff --git a/bauh/gems/appimage/model.py b/bauh/gems/appimage/model.py index 7afa291f..69574ff6 100644 --- a/bauh/gems/appimage/model.py +++ b/bauh/gems/appimage/model.py @@ -48,7 +48,7 @@ class AppImage(SoftwarePackage): categories=None, icon_path: str = None, installed: bool = False, url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False, i18n: I18n = None, install_dir: str = None, updates_ignored: bool = False, - symlink: str = None, **kwargs): + symlink: str = None, manual_update: bool = False, **kwargs): super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version, icon_url=url_icon, license=license, description=description, installed=installed) @@ -66,6 +66,7 @@ class AppImage(SoftwarePackage): self.install_dir = install_dir self.updates_ignored = updates_ignored self.symlink = symlink + self.manual_update = manual_update # True when the user is manually installing/upgrading an AppImage file def __repr__(self): return "{} (name={}, github={})".format(self.__class__.__name__, self.name, self.github)