fix race issue

Signed-off-by: Adam Martin <adam.martin@ranchergovernment.com>
This commit is contained in:
Adam Martin
2026-08-13 21:06:45 -04:00
parent 05e4f6c7e0
commit 15c9d4cb07
+7
View File
@@ -192,6 +192,13 @@ func (o *OCI) AddIndex(desc ocispec.Descriptor) error {
}
}
// Clone the annotations before storing: the caller keeps its own copy of
// desc (AddArtifact returns the very descriptor it passed here), and
// storeFile/fetchChart annotate that copy afterwards to record the
// original reference. Aliasing the same map into nameMap would let those
// unsynchronized writes race saveIndexLocked's iteration, and would also
// make the follow-up AddIndex compare equal to itself and skip the save.
desc.Annotations = maps.Clone(desc.Annotations)
o.nameMap.Store(mapKey, desc)
return o.saveIndexCheckpointLocked()
}