fix: retain DWH key output on ambiguous publication
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user