summaryrefslogtreecommitdiff
path: root/src/import/import.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-21 20:03:57 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-21 20:05:31 +0100
commitff2670ad11a1a29d483b7a246c95b159ddc1137c (patch)
tree2e040aa8272705fe4102d712f4e96480728b49fe /src/import/import.c
parent8b71fce8c2bb0e0a8c2317a34f8f114ff10e6aa6 (diff)
import: simplify dkr importer, by making use of generic import-job logic, used by the raw and tar importers
This gets us progress output as well xz/bzip2 support.
Diffstat (limited to 'src/import/import.c')
-rw-r--r--src/import/import.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/import/import.c b/src/import/import.c
index b3ebb35357..4c36108c2e 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;
}