#include <sys/prctl.h>
#include <curl/curl.h>
-#include "hashmap.h"
#include "utf8.h"
#include "strv.h"
#include "copy.h"
TarImportFinished on_finished;
void *userdata;
- bool finished;
-
char *local;
bool force_local;
if (i->temp_path) {
(void) btrfs_subvol_remove(i->temp_path);
(void) rm_rf_dangerous(i->temp_path, false, true, false);
+ free(i->temp_path);
}
free(i->final_path);
return 0;
}
+static int tar_import_make_local_copy(TarImport *i) {
+ int r;
+
+ assert(i);
+ assert(i->tar_job);
+
+ if (!i->local)
+ return 0;
+
+ if (!i->final_path) {
+ r = import_make_path(i->tar_job->url, i->tar_job->etag, i->image_root, ".tar-", NULL, &i->final_path);
+ if (r < 0)
+ return log_oom();
+
+ r = import_make_local_copy(i->final_path, i->image_root, i->local, i->force_local);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static void tar_import_job_on_finished(ImportJob *j) {
TarImport *i;
int r;
assert(j->userdata);
i = j->userdata;
-
if (j->error != 0) {
r = j->error;
goto finish;
r = log_error_errno(errno, "Failed to rename to final image name: %m");
goto finish;
}
- }
- if (i->local) {
- if (!i->final_path) {
- r = import_make_path(j->url, j->etag, i->image_root, ".tar-", NULL, &i->final_path);
- if (r < 0)
- goto finish;
- }
-
- r = import_make_local_copy(i->final_path, i->image_root, i->local, i->force_local);
- if (r < 0)
- goto finish;
+ free(i->temp_path);
+ i->temp_path = NULL;
}
+ r = tar_import_make_local_copy(i);
+ if (r < 0)
+ goto finish;
+
r = 0;
finish:
- i->finished = true;
-
if (i->on_finished)
i->on_finished(i, r, i->userdata);
else