@@ -91,6 +91,7 @@ type defaultConverter struct {
9191 diffIDMap map [digest.Digest ]digest.Digest // key: old diffID, value: new diffID
9292 ocilayerMap map [string ]bool // key: oci layer digest, value: true
9393 diffIDMapMu sync.RWMutex
94+ ocilayerMapMu sync.RWMutex
9495 hooks ConvertHooks
9596}
9697
@@ -227,7 +228,9 @@ func (c *defaultConverter) convertManifest(ctx context.Context, cs content.Store
227228 c .diffIDMap [oldDiffID ] = newDiffID
228229 c .diffIDMapMu .Unlock ()
229230 }
231+ c .ocilayerMapMu .Lock ()
230232 c .ocilayerMap [newL .Digest .String ()] = true
233+ c .ocilayerMapMu .Unlock ()
231234 }
232235 return nil
233236 })
@@ -355,6 +358,7 @@ func (c *defaultConverter) convertConfig(ctx context.Context, cs content.Store,
355358 if rootfs := cfgAsOCI .RootFS ; rootfs .Type == "layers" {
356359 rootfsModified := false
357360 c .diffIDMapMu .RLock ()
361+ c .ocilayerMapMu .RLock ()
358362 for i , oldDiffID := range rootfs .DiffIDs {
359363 if newDiffID , ok := c .diffIDMap [oldDiffID ]; ok && newDiffID != oldDiffID {
360364 rootfs .DiffIDs [i ] = newDiffID
@@ -364,6 +368,7 @@ func (c *defaultConverter) convertConfig(ctx context.Context, cs content.Store,
364368 rootfs .DiffIDs = slices .Delete (rootfs .DiffIDs , i , i + 1 )
365369 }
366370 }
371+ c .ocilayerMapMu .RUnlock ()
367372 c .diffIDMapMu .RUnlock ()
368373 if rootfsModified {
369374 rootfsB , err := json .Marshal (rootfs )
0 commit comments