Fix bug with removing fpkg from the cache

This commit is contained in:
Kivi Kaitaniemi
2024-05-19 03:41:51 +03:00
parent 06a0f573cd
commit 97b6069080
3 changed files with 16 additions and 10 deletions
+3 -2
View File
@@ -261,11 +261,12 @@ class Core:
self.fpm.install(to_install_fpm, force=self.force_build) self.fpm.install(to_install_fpm, force=self.force_build)
def _create_and_remove_files(self): 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(), self.source.all_file_targets(),
elements_per_line=1, elements_per_line=1,
level=l.INFO) level=l.INFO)
l.print_list("Installing directories:", l.print_list("Directories to install:",
self.source.all_directory_targets(), self.source.all_directory_targets(),
elements_per_line=1, elements_per_line=1,
level=l.INFO) level=l.INFO)
+12 -7
View File
@@ -272,14 +272,20 @@ class Store:
""" """
new_entry = (version, path_to_built_pkg, int(time.time())) new_entry = (version, path_to_built_pkg, int(time.time()))
entries = self._package_file_cache.get(package, []) 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) entries.append(new_entry)
self._package_file_cache[package] = entries self._package_file_cache[package] = entries
self._clean_pkg_cache(package) self._clean_pkg_cache(package)
def _clean_pkg_cache(self, package: str): def _clean_pkg_cache(self, package: str):
oldest_version = None
oldest_path = None oldest_path = None
oldest_timestamp = None oldest_timestamp = None
index_of_oldest = None
entries = self._package_file_cache[package] entries = self._package_file_cache[package]
print_debug(f"Package cache has {len(entries)} entries.") print_debug(f"Package cache has {len(entries)} entries.")
@@ -288,20 +294,19 @@ class Store:
print_debug("Old files will not be removed.") print_debug("Old files will not be removed.")
return return
for entry in entries: for index, entry in enumerate(entries):
version, path, timestamp = entry _, path, timestamp = entry
if oldest_timestamp is None or oldest_timestamp > timestamp: if oldest_timestamp is None or oldest_timestamp > timestamp:
oldest_version = version
oldest_timestamp = timestamp oldest_timestamp = timestamp
oldest_path = path oldest_path = path
index_of_oldest = index
print_debug(f"Oldest cached file for {package} is '{oldest_path}'.") print_debug(f"Oldest cached file for {package} is '{oldest_path}'.")
if oldest_path is None: if oldest_path is None:
return return
assert oldest_version is not None assert index_of_oldest is not None
assert oldest_timestamp is not None
entries.remove((oldest_version, oldest_path, oldest_timestamp)) entries.pop(index_of_oldest)
if os.path.exists(oldest_path): if os.path.exists(oldest_path):
print_debug(f"Removing '{oldest_path}' from the package cache.") print_debug(f"Removing '{oldest_path}' from the package cache.")
try: try:
+1 -1
View File
@@ -1074,7 +1074,7 @@ before and thus are found in the cache."
check=True, check=True,
capture_output=conf.suppress_command_output) 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): default=True):
latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get( latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get(
pkgbase) pkgbase)