@@ -1125,35 +1125,38 @@ func (is *ImageStore) FullBlobUpload(repo string, body io.Reader, dstDigest godi
11251125}
11261126
11271127func (is * ImageStore ) DedupeBlob (src string , dstDigest godigest.Digest , dstRepo string , dst string ) error {
1128- retry:
1129- is .log .Debug ().Str ("src" , src ).Str ("dstDigest" , dstDigest .String ()).Str ("dst" , dst ).Msg ("dedupe begin" )
1128+ for {
1129+ is .log .Debug ().Str ("src" , src ).Str ("dstDigest" , dstDigest .String ()).Str ("dst" , dst ).Msg ("dedupe begin" )
11301130
1131- dstRecord , err := is .cache .GetBlob (dstDigest )
1132- if err := inject .Error (err ); err != nil && ! errors .Is (err , zerr .ErrCacheMiss ) {
1133- is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).Msg ("failed to lookup blob record" )
1134-
1135- return err
1136- }
1137-
1138- if dstRecord == "" {
1139- // cache record doesn't exist, so first disk and cache entry for this digest
1140- if err := is .cache .PutBlob (dstDigest , dst ); err != nil {
1141- is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).
1142- Msg ("failed to insert blob record" )
1131+ dstRecord , err := is .cache .GetBlob (dstDigest )
1132+ if err := inject .Error (err ); err != nil && ! errors .Is (err , zerr .ErrCacheMiss ) {
1133+ is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).Msg ("failed to lookup blob record" )
11431134
11441135 return err
11451136 }
11461137
1147- // move the blob from uploads to final dest
1148- if err := is .storeDriver .Move (src , dst ); err != nil {
1149- is .log .Error ().Err (err ).Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).
1150- Msg ("failed to rename blob" )
1138+ if dstRecord == "" {
1139+ // cache record doesn't exist, so first disk and cache entry for this digest
1140+ if err := is .cache .PutBlob (dstDigest , dst ); err != nil {
1141+ is .log .Error ().Err (err ).Str ("blobPath" , dst ).Str ("component" , "dedupe" ).
1142+ Msg ("failed to insert blob record" )
11511143
1152- return err
1144+ return err
1145+ }
1146+
1147+ // move the blob from uploads to final dest
1148+ if err := is .storeDriver .Move (src , dst ); err != nil {
1149+ is .log .Error ().Err (err ).Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).
1150+ Msg ("failed to rename blob" )
1151+
1152+ return err
1153+ }
1154+
1155+ is .log .Debug ().Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).Msg ("rename" )
1156+
1157+ return nil
11531158 }
11541159
1155- is .log .Debug ().Str ("src" , src ).Str ("dst" , dst ).Str ("component" , "dedupe" ).Msg ("rename" )
1156- } else {
11571160 // cache record exists, but due to GC and upgrades from older versions,
11581161 // disk content and cache records may go out of sync
11591162 if is .cache .UsesRelativePaths () {
@@ -1173,7 +1176,7 @@ retry:
11731176 return err
11741177 }
11751178
1176- goto retry
1179+ continue
11771180 }
11781181
11791182 // prevent overwrite original blob
@@ -1219,9 +1222,9 @@ retry:
12191222 }
12201223
12211224 is .log .Debug ().Str ("src" , src ).Str ("component" , "dedupe" ).Msg ("remove" )
1222- }
12231225
1224- return nil
1226+ return nil
1227+ }
12251228}
12261229
12271230// DeleteBlobUpload deletes an existing blob upload that is currently in progress.
0 commit comments