X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fimport%2Fimport.c;fp=src%2Fimport%2Fimport.c;h=4c36108c2efb8ed58cfaf7f82bc2efceae9a3a7e;hp=b3ebb353570fa09608878ff84e5859171c290037;hb=ff2670ad11a1a29d483b7a246c95b159ddc1137c;hpb=8b71fce8c2bb0e0a8c2317a34f8f114ff10e6aa6 diff --git a/src/import/import.c b/src/import/import.c index b3ebb3535..4c36108c2 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -283,10 +283,8 @@ static void on_dkr_finished(DkrImport *import, int error, void *userdata) { if (error == 0) log_info("Operation completed successfully."); - else - log_error_errno(error, "Operation failed: %m"); - sd_event_exit(event, error); + sd_event_exit(event, EXIT_FAILURE); } static int pull_dkr(int argc, char *argv[], void *userdata) { @@ -338,21 +336,20 @@ static int pull_dkr(int argc, char *argv[], void *userdata) { local = NULL; if (local) { - const char *p; - if (!machine_name_is_valid(local)) { log_error("Local image name '%s' is not valid.", local); return -EINVAL; } - p = strappenda(arg_image_root, "/", local); - if (laccess(p, F_OK) >= 0) { - if (!arg_force) { - log_info("Image '%s' already exists.", local); - return 0; + if (!arg_force) { + r = image_find(local, NULL); + if (r < 0) + return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local); + else if (r > 0) { + log_error_errno(EEXIST, "Image '%s' already exists.", local); + return -EEXIST; } - } else if (errno != ENOENT) - return log_error_errno(errno, "Can't check if image '%s' already exists: %m", local); + } log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local); } else @@ -445,7 +442,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_DKR_INDEX_URL: - if (!dkr_url_is_valid(optarg)) { + if (!http_url_is_valid(optarg)) { log_error("Index URL is not valid: %s", optarg); return -EINVAL; }