mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-22 18:29:56 +00:00
bug: fix removal of the packages
It has been broken since reporter improvements, because it effectivelly 1) didn't call remove functions in database 2) used empty repository identifier for web service With those changes it also raises exception when you try to call id on empty identifier
This commit is contained in:
@ -75,7 +75,9 @@ class Lock(LazyLogging):
|
||||
"""
|
||||
self.path: Path | None = None
|
||||
if args.lock is not None:
|
||||
self.path = args.lock.with_stem(f"{args.lock.stem}_{repository_id.id}")
|
||||
self.path = args.lock
|
||||
if not repository_id.is_empty:
|
||||
self.path = self.path.with_stem(f"{args.lock.stem}_{repository_id.id}")
|
||||
if not self.path.is_absolute():
|
||||
# prepend full path to the lock file
|
||||
self.path = Path("/") / "run" / "ahriman" / self.path
|
||||
|
@ -27,6 +27,7 @@ from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.migrations import Migrations
|
||||
from ahriman.core.database.operations import AuthOperations, BuildOperations, ChangesOperations, \
|
||||
DependenciesOperations, LogsOperations, PackageOperations, PatchOperations
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
# pylint: disable=too-many-ancestors
|
||||
@ -102,23 +103,26 @@ class SQLite(
|
||||
self.with_connection(lambda connection: Migrations.migrate(connection, configuration))
|
||||
paths.chown(self.path)
|
||||
|
||||
def package_clear(self, package_base: str) -> None:
|
||||
def package_clear(self, package_base: str, repository_id: RepositoryId | None = None) -> None:
|
||||
"""
|
||||
completely remove package from all tables
|
||||
|
||||
Args:
|
||||
package_base(str): package base to remove
|
||||
repository_id(RepositoryId, optional): repository unique identifier override (Default value = None)
|
||||
|
||||
Examples:
|
||||
This method completely removes the package from all tables and must be used, e.g. on package removal::
|
||||
|
||||
>>> database.package_clear("ahriman")
|
||||
"""
|
||||
self.build_queue_clear(package_base)
|
||||
self.patches_remove(package_base, [])
|
||||
self.logs_remove(package_base, None)
|
||||
self.changes_remove(package_base)
|
||||
self.dependencies_remove(package_base)
|
||||
self.build_queue_clear(package_base, repository_id)
|
||||
self.patches_remove(package_base, None)
|
||||
self.logs_remove(package_base, None, repository_id)
|
||||
self.changes_remove(package_base, repository_id)
|
||||
self.dependencies_remove(package_base, repository_id)
|
||||
|
||||
self.package_remove(package_base, repository_id)
|
||||
|
||||
# remove local cache too
|
||||
self._repository_paths.tree_clear(package_base)
|
||||
|
@ -184,7 +184,7 @@ class LocalClient(Client):
|
||||
Args:
|
||||
package_base(str): package base to remove
|
||||
"""
|
||||
self.database.package_clear(package_base)
|
||||
self.database.package_clear(package_base, self.repository_id)
|
||||
|
||||
def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
|
@ -140,7 +140,6 @@ class Watcher(LazyLogging):
|
||||
with self._lock:
|
||||
self._known.pop(package_base, None)
|
||||
self.client.package_remove(package_base)
|
||||
self.package_logs_remove(package_base, None)
|
||||
|
||||
def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
|
@ -41,9 +41,12 @@ class RepositoryId:
|
||||
|
||||
Returns:
|
||||
str: unique id for this repository
|
||||
|
||||
Raises:
|
||||
ValueError: if repository identifier is empty
|
||||
"""
|
||||
if self.is_empty:
|
||||
return ""
|
||||
raise ValueError("Repository ID is called on empty repository identifier")
|
||||
return f"{self.architecture}-{self.name}" # basically the same as used for command line
|
||||
|
||||
@property
|
||||
|
Reference in New Issue
Block a user