api: use blob cache path while making hard link

previously mount blob will look for blob that is provided in http request and try to hard link that path
but ideally we should look for path from our cache and do the hard link of that particular path.
this commit does the same.
This commit is contained in:
Shivam Mishra
2021-06-29 11:45:01 -07:00
committed by Ramkumar Chinchani
parent 3a59b9f487
commit af30c06aff
4 changed files with 65 additions and 44 deletions
+5 -5
View File
@@ -497,9 +497,7 @@ func (rh *RouteHandler) CheckBlob(w http.ResponseWriter, r *http.Request) {
return
}
mediaType := r.Header.Get("Accept")
ok, blen, err := is.CheckBlob(name, digest, mediaType)
ok, blen, err := is.CheckBlob(name, digest)
if err != nil {
switch err {
case errors.ErrBadBlobDigest:
@@ -662,8 +660,10 @@ func (rh *RouteHandler) CreateBlobUpload(w http.ResponseWriter, r *http.Request)
return
}
// zot does not support cross mounting directly and do a workaround by copying blob using hard link
err := is.MountBlob(name, from[0], mountDigests[0])
// zot does not support cross mounting directly and do a workaround creating using hard link.
// check blob looks for actual path (name+mountDigests[0]) first then look for cache and
// if found in cache, will do hard link and if fails we will start new upload.
_, _, err := is.CheckBlob(name, mountDigests[0])
if err != nil {
u, err := is.NewBlobUpload(name)
if err != nil {