forked from forgejo/forgejo
Backport #20977 Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran. Fix #20969 Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
parent
ea416d7d0e
commit
7888a55e8c
2 changed files with 78 additions and 2 deletions
|
@ -214,9 +214,16 @@ func FindUnreferencedPackages(ctx context.Context) ([]*Package, error) {
|
|||
Find(&ps)
|
||||
}
|
||||
|
||||
// HasOwnerPackages tests if a user/org has packages
|
||||
// HasOwnerPackages tests if a user/org has accessible packages
|
||||
func HasOwnerPackages(ctx context.Context, ownerID int64) (bool, error) {
|
||||
return db.GetEngine(ctx).Where("owner_id = ?", ownerID).Exist(&Package{})
|
||||
return db.GetEngine(ctx).
|
||||
Table("package_version").
|
||||
Join("INNER", "package", "package.id = package_version.package_id").
|
||||
Where(builder.Eq{
|
||||
"package_version.is_internal": false,
|
||||
"package.owner_id": ownerID,
|
||||
}).
|
||||
Exist(&PackageVersion{})
|
||||
}
|
||||
|
||||
// HasRepositoryPackages tests if a repository has packages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue