mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[fix] ignore updates file handling for Arch, AppImage and Flatpak
This commit is contained in:
@@ -316,6 +316,8 @@ class AppImageManager(SoftwareManager):
|
||||
if os.path.exists(de_path):
|
||||
os.remove(de_path)
|
||||
|
||||
self.revert_ignored_update(pkg)
|
||||
|
||||
return True
|
||||
|
||||
def get_managed_types(self) -> Set[Type[SoftwarePackage]]:
|
||||
@@ -723,8 +725,11 @@ class AppImageManager(SoftwareManager):
|
||||
ignored_list.sort()
|
||||
|
||||
with open(UPDATES_IGNORED_FILE, 'w+') as f:
|
||||
for ignored in ignored_list:
|
||||
f.write('{}\n'.format(ignored))
|
||||
if ignored_list:
|
||||
for ignored in ignored_list:
|
||||
f.write('{}\n'.format(ignored))
|
||||
else:
|
||||
f.write('')
|
||||
|
||||
def revert_ignored_update(self, pkg: AppImage):
|
||||
current_ignored = self._read_ignored_updates()
|
||||
|
||||
@@ -2259,35 +2259,50 @@ class ArchManager(SoftwareManager):
|
||||
return True
|
||||
|
||||
def _list_ignored_updates(self) -> Set[str]:
|
||||
ignored = set()
|
||||
if os.path.exists(UPDATES_IGNORED_FILE):
|
||||
with open(UPDATES_IGNORED_FILE) as f:
|
||||
return {line.strip() for line in f.read().split('\n') if line}
|
||||
ignored_lines = f.readlines()
|
||||
|
||||
for line in ignored_lines:
|
||||
if line:
|
||||
line_clean = line.strip()
|
||||
|
||||
if line_clean:
|
||||
ignored.add(line_clean)
|
||||
|
||||
return ignored
|
||||
|
||||
def _write_ignored(self, names: Set[str]):
|
||||
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
|
||||
ignored_list = [*names]
|
||||
ignored_list.sort()
|
||||
|
||||
with open(UPDATES_IGNORED_FILE, 'w+') as f:
|
||||
if ignored_list:
|
||||
for pkg in ignored_list:
|
||||
f.write('{}\n'.format(pkg))
|
||||
else:
|
||||
f.write('')
|
||||
|
||||
def ignore_update(self, pkg: ArchPackage):
|
||||
ignored = self._list_ignored_updates()
|
||||
|
||||
if not ignored or pkg.name not in ignored:
|
||||
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
|
||||
if pkg.name not in ignored:
|
||||
ignored.add(pkg.name)
|
||||
self._write_ignored(ignored)
|
||||
|
||||
with open(UPDATES_IGNORED_FILE, 'a+') as f:
|
||||
f.write('{}\n'.format(pkg.name))
|
||||
|
||||
pkg.update_ignored = True
|
||||
pkg.update_ignored = True
|
||||
|
||||
def _revert_ignored_updates(self, pkgs: Iterable[str]):
|
||||
if os.path.exists(UPDATES_IGNORED_FILE):
|
||||
ignored = []
|
||||
with open(UPDATES_IGNORED_FILE) as f:
|
||||
for line in f.read().split('\n'):
|
||||
if line:
|
||||
clean_line = line.strip()
|
||||
ignored = self._list_ignored_updates()
|
||||
|
||||
if clean_line and clean_line not in pkgs:
|
||||
ignored.append(clean_line)
|
||||
for p in pkgs:
|
||||
if p in ignored:
|
||||
ignored.remove(p)
|
||||
|
||||
with open(UPDATES_IGNORED_FILE, 'w+') as f:
|
||||
f.writelines(ignored)
|
||||
self._write_ignored(ignored)
|
||||
|
||||
def revert_ignored_update(self, pkg: ArchPackage):
|
||||
self._revert_ignored_updates({pkg.name})
|
||||
pkg.update_ignored = False
|
||||
pkg.update_ignored = False
|
||||
|
||||
@@ -232,6 +232,8 @@ class FlatpakManager(SoftwareManager):
|
||||
if self.suggestions_cache:
|
||||
self.suggestions_cache.delete(pkg.id)
|
||||
|
||||
self.revert_ignored_update(pkg)
|
||||
|
||||
return uninstalled
|
||||
|
||||
def get_info(self, app: FlatpakApplication) -> dict:
|
||||
@@ -568,8 +570,11 @@ class FlatpakManager(SoftwareManager):
|
||||
ignored_list.sort()
|
||||
|
||||
with open(UPDATES_IGNORED_FILE, 'w+') as f:
|
||||
for ignored in ignored_list:
|
||||
f.write('{}\n'.format(ignored))
|
||||
if ignored_list:
|
||||
for ignored in ignored_list:
|
||||
f.write('{}\n'.format(ignored))
|
||||
else:
|
||||
f.write('')
|
||||
|
||||
def ignore_update(self, pkg: FlatpakApplication):
|
||||
ignored_keys = self._read_ignored_updates()
|
||||
|
||||
Reference in New Issue
Block a user