import: remove misplaced assert()
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Jun 2017 18:25:07 +0000 (20:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 26 Jun 2017 18:25:07 +0000 (20:25 +0200)
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
src/import/pull-tar.c

index 974e42d..fe20803 100644 (file)
@@ -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);
index 16ce901..482beb7 100644 (file)
@@ -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;