fix: retain DWH key output on ambiguous publication

This commit is contained in:
User
2026-08-21 01:29:04 +02:00
parent 055dcabf36
commit b1079bda21
2 changed files with 54 additions and 5 deletions
+13 -5
View File
@@ -236,9 +236,9 @@ func runCreate(ctx context.Context, root string, args []string, stdout, stderr i
}
addErr := addRecord(store, value)
if addErr != nil {
lookupErr := lookupCreatedRecord(store, material.KeyID)
present, snapshotErr := snapshotContainsKey(store, material.KeyID)
closeErr := closeStore(store)
if errors.Is(lookupErr, registry.ErrNotFound) && closeErr == nil {
if snapshotErr == nil && !present && closeErr == nil {
if cleanupOutput(options.output) != nil {
writeCleanupFailure(stderr, options.output)
return exitIntegrity
@@ -448,9 +448,17 @@ func runServe(args []string, stderr io.Writer) int {
return exitIntegrity
}
func lookupCreatedRecord(store *registry.Store, keyID string) error {
_, err := store.Find(keyID)
return err
func snapshotContainsKey(store *registry.Store, keyID string) (bool, error) {
values, err := store.List()
if err != nil {
return false, err
}
for _, value := range values {
if value.KeyID == keyID {
return true, nil
}
}
return false, nil
}
func openCheckedStore(ctx context.Context, root string) (*registry.Store, error) {