mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
Fix file handlers not being closed after calls to ImageStore.GetBlob
This is to fixes hitting the FD limit when reading blobs from the disk in the graphql API Signed-off-by: Andrei Aaron <andaaron@cisco.com>
This commit is contained in:
committed by
Ramkumar Chinchani
parent
74630ed3a0
commit
bd9ad998cd
@@ -655,6 +655,7 @@ func (rh *RouteHandler) GetBlob(response http.ResponseWriter, request *http.Requ
|
||||
|
||||
return
|
||||
}
|
||||
defer repo.Close()
|
||||
|
||||
response.Header().Set("Content-Length", fmt.Sprintf("%d", blen))
|
||||
response.Header().Set(constants.DistContentDigestKey, digest)
|
||||
|
||||
@@ -405,8 +405,8 @@ func TestRoutes(t *testing.T) {
|
||||
"digest": "sha256:7a0437f04f83f084b7ed68ad9c4a4947e12fc4e1b006b38129bac89114ec3621",
|
||||
},
|
||||
&mocks.MockedImageStore{
|
||||
GetBlobFn: func(repo, digest, mediaType string) (io.Reader, int64, error) {
|
||||
return bytes.NewBuffer([]byte("")), 0, zerr.ErrRepoNotFound
|
||||
GetBlobFn: func(repo, digest, mediaType string) (io.ReadCloser, int64, error) {
|
||||
return io.NopCloser(bytes.NewBuffer([]byte(""))), 0, zerr.ErrRepoNotFound
|
||||
},
|
||||
})
|
||||
So(statusCode, ShouldEqual, http.StatusNotFound)
|
||||
@@ -418,8 +418,8 @@ func TestRoutes(t *testing.T) {
|
||||
"digest": "sha256:7a0437f04f83f084b7ed68ad9c4a4947e12fc4e1b006b38129bac89114ec3621",
|
||||
},
|
||||
&mocks.MockedImageStore{
|
||||
GetBlobFn: func(repo, digest, mediaType string) (io.Reader, int64, error) {
|
||||
return bytes.NewBuffer([]byte("")), 0, zerr.ErrBadBlobDigest
|
||||
GetBlobFn: func(repo, digest, mediaType string) (io.ReadCloser, int64, error) {
|
||||
return io.NopCloser(bytes.NewBuffer([]byte(""))), 0, zerr.ErrBadBlobDigest
|
||||
},
|
||||
})
|
||||
So(statusCode, ShouldEqual, http.StatusBadRequest)
|
||||
|
||||
Reference in New Issue
Block a user