feat: optimize the FindUnreferencedPackages package query
Replace a double select with a simple select. The complication originates from the initial implementation which deleted packages instead of selecting them. It was justified to workaround a problem in MySQL. But it is just a waste of resources when collecting a list of IDs.
This commit is contained in:
parent
dac78913aa
commit
ff6aceaeac
3 changed files with 18 additions and 16 deletions
|
@ -479,6 +479,8 @@ func TestPackageCleanup(t *testing.T) {
|
|||
AddBasicAuth(user.Name)
|
||||
MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &packages_model.Package{Name: "cleanup-test"})
|
||||
|
||||
pbs, err := packages_model.FindExpiredUnreferencedBlobs(db.DefaultContext, duration)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, pbs)
|
||||
|
@ -493,6 +495,8 @@ func TestPackageCleanup(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Empty(t, pbs)
|
||||
|
||||
unittest.AssertNotExistsBean(t, &packages_model.Package{Name: "cleanup-test"})
|
||||
|
||||
_, err = packages_model.GetInternalVersionByNameAndVersion(db.DefaultContext, user.ID, packages_model.TypeContainer, "cleanup-test", container_model.UploadVersion)
|
||||
assert.ErrorIs(t, err, packages_model.ErrPackageNotExist)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue