Add API to support link package to repository and unlink it (#33481)

Fix #21062

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
(cherry picked from commit 5df9fd3e9c6ae7f848da65dbe9b9d321f29c003a)
This commit is contained in:
Lunny Xiao 2025-02-16 19:18:00 -08:00 committed by Gusted
parent b74a967c92
commit e09ea821bd
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 334 additions and 14 deletions

View file

@ -242,6 +242,11 @@ func SetRepositoryLink(ctx context.Context, packageID, repoID int64) error {
return err
}
func UnlinkRepository(ctx context.Context, packageID int64) error {
_, err := db.GetEngine(ctx).ID(packageID).Cols("repo_id").Update(&Package{RepoID: 0})
return err
}
// UnlinkRepositoryFromAllPackages unlinks every package from the repository
func UnlinkRepositoryFromAllPackages(ctx context.Context, repoID int64) error {
_, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Cols("repo_id").Update(&Package{})