summaryrefslogtreecommitdiffstats
path: root/models/packages/package.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-04-06 03:32:09 +0200
committerGitHub <noreply@github.com>2022-04-06 03:32:09 +0200
commit5e242e021b9f32d2d136e4f3324cb56be415f484 (patch)
tree01bde0162b15ecb069d13d53413dfbb5d514a945 /models/packages/package.go
parent8ddcd37f13411f38a7e4bbd1c1f931436af255b6 (diff)
downloadgitea-5e242e021b9f32d2d136e4f3324cb56be415f484.tar.gz
gitea-5e242e021b9f32d2d136e4f3324cb56be415f484.zip
Package registry changes (#19305)
* removed debug logs * fixed SELECT * removed unneeded error type * use common SearchVersions method * remove empty container upload versions * return err
Diffstat (limited to 'models/packages/package.go')
-rw-r--r--models/packages/package.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/models/packages/package.go b/models/packages/package.go
index 05170ab3f4..373bd86d9f 100644
--- a/models/packages/package.go
+++ b/models/packages/package.go
@@ -190,13 +190,15 @@ func GetPackagesByType(ctx context.Context, ownerID int64, packageType Type) ([]
// DeletePackagesIfUnreferenced deletes a package if there are no associated versions
func DeletePackagesIfUnreferenced(ctx context.Context) error {
in := builder.
- Select("package_version.package_id").
+ Select("package.id").
From("package").
- Join("LEFT", "package_version", "package_version.package_id = package.id").
+ LeftJoin("package_version", "package_version.package_id = package.id").
Where(builder.Expr("package_version.id IS NULL"))
_, err := db.GetEngine(ctx).
- Where(builder.In("package.id", in)).
+ // double select workaround for MySQL
+ // https://stackoverflow.com/questions/4471277/mysql-delete-from-with-subquery-as-condition
+ Where(builder.In("package.id", builder.Select("id").From(in, "temp"))).
Delete(&Package{})
return err