From 97b60690809bc2773f606246ab8dc060b9bb9797 Mon Sep 17 00:00:00 2001 From: Kivi Kaitaniemi Date: Sun, 19 May 2024 03:41:51 +0300 Subject: [PATCH] Fix bug with removing fpkg from the cache --- src/decman/app.py | 5 +++-- src/decman/lib/__init__.py | 19 ++++++++++++------- src/decman/lib/fpm.py | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/decman/app.py b/src/decman/app.py index db47026..557b7fe 100644 --- a/src/decman/app.py +++ b/src/decman/app.py @@ -261,11 +261,12 @@ class Core: self.fpm.install(to_install_fpm, force=self.force_build) def _create_and_remove_files(self): - l.print_list("Installing files:", + l.print_summary("Installing files.") + l.print_list("Files to install:", self.source.all_file_targets(), elements_per_line=1, level=l.INFO) - l.print_list("Installing directories:", + l.print_list("Directories to install:", self.source.all_directory_targets(), elements_per_line=1, level=l.INFO) diff --git a/src/decman/lib/__init__.py b/src/decman/lib/__init__.py index 904c3da..c61dae9 100644 --- a/src/decman/lib/__init__.py +++ b/src/decman/lib/__init__.py @@ -272,14 +272,20 @@ class Store: """ new_entry = (version, path_to_built_pkg, int(time.time())) entries = self._package_file_cache.get(package, []) + for _, already_cached_path, __ in entries: + if already_cached_path == path_to_built_pkg: + print_debug( + f"Trying to cache {package} version {version}, but the version is already cached: {already_cached_path}" + ) + return entries.append(new_entry) self._package_file_cache[package] = entries self._clean_pkg_cache(package) def _clean_pkg_cache(self, package: str): - oldest_version = None oldest_path = None oldest_timestamp = None + index_of_oldest = None entries = self._package_file_cache[package] print_debug(f"Package cache has {len(entries)} entries.") @@ -288,20 +294,19 @@ class Store: print_debug("Old files will not be removed.") return - for entry in entries: - version, path, timestamp = entry + for index, entry in enumerate(entries): + _, path, timestamp = entry if oldest_timestamp is None or oldest_timestamp > timestamp: - oldest_version = version oldest_timestamp = timestamp oldest_path = path + index_of_oldest = index print_debug(f"Oldest cached file for {package} is '{oldest_path}'.") if oldest_path is None: return - assert oldest_version is not None - assert oldest_timestamp is not None + assert index_of_oldest is not None - entries.remove((oldest_version, oldest_path, oldest_timestamp)) + entries.pop(index_of_oldest) if os.path.exists(oldest_path): print_debug(f"Removing '{oldest_path}' from the package cache.") try: diff --git a/src/decman/lib/fpm.py b/src/decman/lib/fpm.py index 3784911..7f14c4f 100644 --- a/src/decman/lib/fpm.py +++ b/src/decman/lib/fpm.py @@ -1074,7 +1074,7 @@ before and thus are found in the cache." check=True, capture_output=conf.suppress_command_output) - if l.prompt_confirm(f"Review PKGBUILD for {pkgbase}?", + if l.prompt_confirm(f"Review PKGBUILD or show diff for {pkgbase}?", default=True): latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get( pkgbase)