From 461d8b53c2e51a8a6a1715ba40ac61d7e9f93971 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 19 Jan 2024 12:37:10 +0100 Subject: Fix some RPM registry flaws (#28782) Related #26984 (https://github.com/go-gitea/gitea/pull/26984#issuecomment-1889588912) Fix admin cleanup message. Fix models `Get` not respecting default values. Rebuild RPM repository files after cleanup. Do not add RPM group to package version name. Force stable sorting of Alpine/Debian/RPM repository data. Fix missing deferred `Close`. Add tests for multiple RPM groups. Removed non-cached `ReplaceAllStringRegex`. If there are multiple groups available, it's stated in the package installation screen: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/8f132760-882c-4ab8-9678-77e47dfc4415) --- models/packages/package_version.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'models/packages/package_version.go') diff --git a/models/packages/package_version.go b/models/packages/package_version.go index 9999fc4dab..8fc475691b 100644 --- a/models/packages/package_version.go +++ b/models/packages/package_version.go @@ -39,17 +39,17 @@ type PackageVersion struct { func GetOrInsertVersion(ctx context.Context, pv *PackageVersion) (*PackageVersion, error) { e := db.GetEngine(ctx) - key := &PackageVersion{ - PackageID: pv.PackageID, - LowerVersion: pv.LowerVersion, - } + existing := &PackageVersion{} - has, err := e.Get(key) + has, err := e.Where(builder.Eq{ + "package_id": pv.PackageID, + "lower_version": pv.LowerVersion, + }).Get(existing) if err != nil { return nil, err } if has { - return key, ErrDuplicatePackageVersion + return existing, ErrDuplicatePackageVersion } if _, err = e.Insert(pv); err != nil { return nil, err -- cgit v1.2.3