@@ -1135,35 +1135,38 @@ func (is *ImageStore) FullBlobUpload(repo string, body io.Reader, dstDigest godi
11351135}
11361136
11371137func (is * ImageStore ) DedupeBlob (src string , dstDigest godigest.Digest , dstRepo string , dst string ) error {
1138- retry:
1139- is .log .Debug ().Str ("src" , src ).Str ("dstDigest" , dstDigest .String ()).Str ("dst" , dst ).Msg ("dedupe begin" )
1138+ for {
1139+ is .log .Debug ().Str ("src" , src ).Str ("dstDigest" , dstDigest .String ()).Str ("dst" , dst ).Msg ("dedupe begin" )
11401140
1141- dstRecord , err := is .cache .GetBlob (dstDigest )
1142- if err := inject .Error (err ); err != nil && ! errors .Is (err , zerr .ErrCacheMiss ) {
1143- is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).Msg ("failed to lookup blob record" )
1144-
1145- return err
1146- }
1147-
1148- if dstRecord == "" {
1149- // cache record doesn't exist, so first disk and cache entry for this digest
1150- if err := is .cache .PutBlob (dstDigest , dst ); err != nil {
1151- is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).
1152- Msg ("failed to insert blob record" )
1141+ dstRecord , err := is .cache .GetBlob (dstDigest )
1142+ if err := inject .Error (err ); err != nil && ! errors .Is (err , zerr .ErrCacheMiss ) {
1143+ is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).Msg ("failed to lookup blob record" )
11531144
11541145 return err
11551146 }
11561147
1157- // move the blob from uploads to final dest
1158- if err := is .storeDriver .Move (src , dst ); err != nil {
1159- is .log .Error ().Err (err ).Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).
1160- Msg ("failed to rename blob" )
1148+ if dstRecord == "" {
1149+ // cache record doesn't exist, so first disk and cache entry for this digest
1150+ if err := is .cache .PutBlob (dstDigest , dst ); err != nil {
1151+ is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).
1152+ Msg ("failed to insert blob record" )
11611153
1162- return err
1154+ return err
1155+ }
1156+
1157+ // move the blob from uploads to final dest
1158+ if err := is .storeDriver .Move (src , dst ); err != nil {
1159+ is .log .Error ().Err (err ).Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).
1160+ Msg ("failed to rename blob" )
1161+
1162+ return err
1163+ }
1164+
1165+ is .log .Debug ().Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).Msg ("rename" )
1166+
1167+ return nil
11631168 }
11641169
1165- is .log .Debug ().Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).Msg ("rename" )
1166- } else {
11671170 // cache record exists, but due to GC and upgrades from older versions,
11681171 // disk content and cache records may go out of sync
11691172 if is .cache .UsesRelativePaths () {
@@ -1183,7 +1186,7 @@ retry:
11831186 return err
11841187 }
11851188
1186- goto retry
1189+ continue
11871190 }
11881191
11891192 // prevent overwrite original blob
@@ -1229,9 +1232,9 @@ retry:
12291232 }
12301233
12311234 is .log .Debug ().Str ("src" , src ).Str ("component" , "dedupe" ).Msg ("remove" )
1232- }
12331235
1234- return nil
1236+ return nil
1237+ }
12351238}
12361239
12371240// DeleteBlobUpload deletes an existing blob upload that is currently in progress.
0 commit comments