aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages/package_version.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2024-01-19 12:37:10 +0100
committerGitHub <noreply@github.com>2024-01-19 11:37:10 +0000
commit461d8b53c2e51a8a6a1715ba40ac61d7e9f93971 (patch)
tree2bad0b2908f9f3e76d9a195c4fe1c66016b8bcbf /models/packages/package_version.go
parent075c4c89ee28590bd4ab8f6cf7338d723c4696eb (diff)
downloadgitea-461d8b53c2e51a8a6a1715ba40ac61d7e9f93971.tar.gz
gitea-461d8b53c2e51a8a6a1715ba40ac61d7e9f93971.zip
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)
Diffstat (limited to 'models/packages/package_version.go')
-rw-r--r--models/packages/package_version.go12
1 files changed, 6 insertions, 6 deletions
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