From e0061812b00db3c8226ad845d3c2741d5c5fc86e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Jun 2017 20:25:07 +0200 Subject: [PATCH 1/2] import: remove misplaced assert() We shouldn't assume the final path for the settings file is already known, it unlikely is unless we already downloaded the image once. Also add some commenting to explain the code surrounding the assert a bit. Fixes: #6188 --- src/import/pull-raw.c | 2 +- src/import/pull-tar.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index 974e42d7ce..fe208032b2 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -444,7 +444,7 @@ static int raw_pull_rename_auxiliary_file( assert(suffix); assert(path); - /* Regenerate final name for this auxiliary file, we might know the etag of the raw file now, and we shoud + /* Regenerate final name for this auxiliary file, we might know the etag of the file now, and we should * incorporate it in the file name if we can */ *path = mfree(*path); r = raw_pull_determine_path(i, suffix, path); diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 16ce901650..482beb7cd2 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -114,6 +114,7 @@ TarPull* tar_pull_unref(TarPull *i) { free(i->settings_path); free(i->image_root); free(i->local); + return mfree(i); } @@ -367,13 +368,14 @@ static void tar_pull_job_on_finished(PullJob *j) { if (i->settings_job && i->settings_job->error == 0) { - assert(i->settings_temp_path); - assert(i->settings_path); - - /* Also move the settings file into place, if it exist. Note that we do so only if we also + /* Also move the settings file into place, if it exists. Note that we do so only if we also * moved the tar file in place, to keep things strictly in sync. */ + assert(i->settings_temp_path); + /* Regenerate final name for this auxiliary file, we might know the etag of the file now, and + * we should incorporate it in the file name if we can */ i->settings_path = mfree(i->settings_path); + r = tar_pull_determine_path(i, ".nspawn", &i->settings_path); if (r < 0) goto finish; From dc38f65a729d1f4143a9fe21605152c6391ced73 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Jun 2017 20:32:40 +0200 Subject: [PATCH 2/2] importd: log more information when renaming files --- src/import/pull-raw.c | 2 +- src/import/pull-tar.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index fe208032b2..b45ac814a9 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -538,7 +538,7 @@ static void raw_pull_job_on_finished(PullJob *j) { r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path); if (r < 0) { - log_error_errno(r, "Failed to move RAW file into place: %m"); + log_error_errno(r, "Failed to rename raw file to %s: %m", i->final_path); goto finish; } diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 482beb7cd2..12211a6fc6 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -359,7 +359,7 @@ static void tar_pull_job_on_finished(PullJob *j) { r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path); if (r < 0) { - log_error_errno(r, "Failed to rename to final image name: %m"); + log_error_errno(r, "Failed to rename to final image name to %s: %m", i->final_path); goto finish; } @@ -386,7 +386,7 @@ static void tar_pull_job_on_finished(PullJob *j) { r = rename_noreplace(AT_FDCWD, i->settings_temp_path, AT_FDCWD, i->settings_path); if (r < 0) { - log_error_errno(r, "Failed to rename settings file: %m"); + log_error_errno(r, "Failed to rename settings file to %s: %m", i->settings_path); goto finish; }