From c783ce17be9c9225de2fa26f3935414f4b2be32a Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 4 Feb 2022 19:55:36 -0800 Subject: [PATCH 1/3] fix: remove erroneous official pkg check This causes an issue that should have been obvious from the get-go: if a package request is up in the AUR, but the package has already been picked up by an official repository, we would end up returning a 404 here, leading a TU to not be able to perform an action for a request's target. Signed-off-by: Kevin Morris --- aurweb/packages/util.py | 7 ------- test/test_packages_routes.py | 15 --------------- 2 files changed, 22 deletions(-) diff --git a/aurweb/packages/util.py b/aurweb/packages/util.py index 21b5fab8..ded1554f 100644 --- a/aurweb/packages/util.py +++ b/aurweb/packages/util.py @@ -98,17 +98,10 @@ def get_pkg_or_base( :raises HTTPException: With status code 404 if record doesn't exist :return: {Package,PackageBase} instance """ - provider = db.query(models.OfficialProvider).filter( - models.OfficialProvider.Name == name).first() - if provider: - raise HTTPException(status_code=HTTPStatus.NOT_FOUND) - with db.begin(): instance = db.query(cls).filter(cls.Name == name).first() - if not instance: raise HTTPException(status_code=HTTPStatus.NOT_FOUND) - return instance diff --git a/test/test_packages_routes.py b/test/test_packages_routes.py index adafe1ae..ee837912 100644 --- a/test/test_packages_routes.py +++ b/test/test_packages_routes.py @@ -203,21 +203,6 @@ def test_package_not_found(client: TestClient): assert resp.status_code == int(HTTPStatus.NOT_FOUND) -def test_package_official_not_found(client: TestClient, package: Package): - """ When a Package has a matching OfficialProvider record, it is not - hosted on AUR, but in the official repositories. Getting a package - with this kind of record should return a status code 404. """ - with db.begin(): - db.create(OfficialProvider, - Name=package.Name, - Repo="core", - Provides=package.Name) - - with client as request: - resp = request.get(package_endpoint(package)) - assert resp.status_code == int(HTTPStatus.NOT_FOUND) - - def test_package(client: TestClient, package: Package): """ Test a single / packages / {name} route. """ From b7bf83c5f01c9953a5f286517ec5272d62ad79ca Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 4 Feb 2022 20:13:24 -0800 Subject: [PATCH 2/3] fix: prioritize local db record in pkgname_link Signed-off-by: Kevin Morris --- aurweb/packages/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aurweb/packages/util.py b/aurweb/packages/util.py index ded1554f..0a259e1e 100644 --- a/aurweb/packages/util.py +++ b/aurweb/packages/util.py @@ -61,12 +61,16 @@ def dep_extra_desc(dep: models.PackageDependency) -> str: @register_filter("pkgname_link") def pkgname_link(pkgname: str) -> str: + record = db.query(Package).filter( + Package.Name == pkgname).exists() + if db.query(record).scalar(): + return f"/packages/{pkgname}" + official = db.query(OfficialProvider).filter( OfficialProvider.Name == pkgname).exists() if db.query(official).scalar(): base = "/".join([OFFICIAL_BASE, "packages"]) return f"{base}/?q={pkgname}" - return f"/packages/{pkgname}" @register_filter("package_link") From 3cb106bc9d9ca276ab306983eb029bb0134fef3c Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 4 Feb 2022 20:23:28 -0800 Subject: [PATCH 3/3] upgrade: bump to v6.0.6 Signed-off-by: Kevin Morris --- aurweb/config.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aurweb/config.py b/aurweb/config.py index 6cf0b0ef..1a9b0719 100644 --- a/aurweb/config.py +++ b/aurweb/config.py @@ -6,7 +6,7 @@ from typing import Any # Publicly visible version of aurweb. This is used to display # aurweb versioning in the footer and must be maintained. # Todo: Make this dynamic/automated. -AURWEB_VERSION = "v6.0.5" +AURWEB_VERSION = "v6.0.6" _parser = None diff --git a/pyproject.toml b/pyproject.toml index ae7db89c..f2f5847d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ # [tool.poetry] name = "aurweb" -version = "v6.0.5" +version = "v6.0.6" license = "GPL-2.0-only" description = "Source code for the Arch User Repository's website" homepage = "https://aur.archlinux.org"