diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/core/delivery_init.c | 24 | 
1 files changed, 13 insertions, 11 deletions
| diff --git a/src/lib/core/delivery_init.c b/src/lib/core/delivery_init.c index 356a8ce..7e51f24 100644 --- a/src/lib/core/delivery_init.c +++ b/src/lib/core/delivery_init.c @@ -320,25 +320,27 @@ int delivery_exists(struct Delivery *ctx) {          }          struct JFRT_Search search = {.fail_no_op = true}; +        // release_exists error states: +        //   `jf rt search --fail_no_op` returns 2 on failure +        //   otherwise, search returns an empty list "[]" and returns 0          release_exists = jfrog_cli_rt_search(&ctx->deploy.jfrog_auth, &search, globals.jfrog.repo, release_pattern); -        if (release_exists != 2) { -            if (!globals.enable_overwrite && !release_exists) { -                // --fail_no_op returns 2 on failure -                // without: it returns an empty list "[]" and exit code 0 -                return 1;  // found -            } -        }      } else {          struct StrList *files = listdir(ctx->storage.delivery_dir);          for (size_t i = 0; i < strlist_count(files); i++) {              char *filename = strlist_item(files, i);              release_exists = fnmatch(release_pattern, filename, FNM_PATHNAME); -            if (!globals.enable_overwrite && !release_exists) { -                guard_strlist_free(&files); -                return 1;  // found +            if (!release_exists) { +                break;              }          }          guard_strlist_free(&files);      } -    return 0;  // not found + +    if (release_exists < 0) { +        return -1;  // error +    } +    if (release_exists >= 1) { +        return DELIVERY_NOT_FOUND; +    } +    return DELIVERY_FOUND;  } | 
