mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
fix: don't allow blobs to be deleted if in use (#1559)
dist-spec APIs independently allow deletion of blobs and manifests. Doing the former when in use by an image manifest or index is simply error-prone. So disallow it. Fixes issue #1509 Signed-off-by: Petu Eusebiu <peusebiu@cisco.com> Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com> Co-authored-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
+6
-6
@@ -77,6 +77,12 @@ func deleteTestRepo(repos []string, url string, client *resty.Client) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete manifest so that we don't trigger BlobInUse error
|
||||
err = makeHTTPDeleteRequest(fmt.Sprintf("%s/v2/%s/manifests/%s", url, repo, tag), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete blobs
|
||||
for _, blob := range manifest.Layers {
|
||||
err := makeHTTPDeleteRequest(fmt.Sprintf("%s/v2/%s/blobs/%s", url, repo, blob.Digest.String()), client)
|
||||
@@ -90,12 +96,6 @@ func deleteTestRepo(repos []string, url string, client *resty.Client) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete manifest
|
||||
err = makeHTTPDeleteRequest(fmt.Sprintf("%s/v2/%s/manifests/%s", url, repo, tag), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user