@@ -53,6 +53,8 @@ func (m *MemoryWithDelete) Index(ctx context.Context, fetcher content.Fetcher, n
53
53
return err
54
54
}
55
55
56
+ m .lock .Lock ()
57
+ defer m .lock .Unlock ()
56
58
m .index (ctx , node , successors )
57
59
return nil
58
60
}
@@ -96,6 +98,8 @@ func (m *MemoryWithDelete) IndexAll(ctx context.Context, fetcher content.Fetcher
96
98
}
97
99
return nil
98
100
}
101
+ m .lock .Lock ()
102
+ defer m .lock .Unlock ()
99
103
return syncutil .Go (ctx , nil , fn , node )
100
104
}
101
105
@@ -120,9 +124,9 @@ func (m *MemoryWithDelete) Predecessors(_ context.Context, node ocispec.Descript
120
124
121
125
// Remove removes the node from its predecessors and successors.
122
126
func (m * MemoryWithDelete ) Remove (ctx context.Context , node ocispec.Descriptor ) error {
127
+ nodeKey := descriptor .FromOCI (node )
123
128
m .lock .Lock ()
124
129
defer m .lock .Unlock ()
125
- nodeKey := descriptor .FromOCI (node )
126
130
// remove the node from its successors' predecessor list
127
131
for successorKey := range m .successors [nodeKey ] {
128
132
delete (m .predecessors [successorKey ], nodeKey )
@@ -135,8 +139,6 @@ func (m *MemoryWithDelete) Remove(ctx context.Context, node ocispec.Descriptor)
135
139
// There is no data consistency issue as long as deletion is not implemented
136
140
// for the underlying storage.
137
141
func (m * MemoryWithDelete ) index (ctx context.Context , node ocispec.Descriptor , successors []ocispec.Descriptor ) {
138
- m .lock .Lock ()
139
- defer m .lock .Unlock ()
140
142
m .createEntriesInMaps (ctx , node )
141
143
if len (successors ) == 0 {
142
144
return
0 commit comments