- i->glue->on_finished = raw_import_curl_on_finished;
- i->glue->userdata = i;
-
- *import = i;
- i = NULL;
-
- return 0;
-}
-
-RawImport* raw_import_unref(RawImport *import) {
- RawImportFile *f;
-
- if (!import)
- return NULL;
-
- while ((f = hashmap_steal_first(import->files)))
- raw_import_file_unref(f);
- hashmap_free(import->files);
-
- curl_glue_unref(import->glue);
- sd_event_unref(import->event);
-
- free(import->image_root);
- free(import);
-
- return NULL;
-}
-
-int raw_import_cancel(RawImport *import, const char *url) {
- RawImportFile *f;
-
- assert(import);
- assert(url);
-
- f = hashmap_remove(import->files, url);
- if (!f)
- return 0;
-
- raw_import_file_unref(f);
- return 1;
-}
-
-int raw_import_pull(RawImport *import, const char *url, const char *local, bool force_local) {
- _cleanup_(raw_import_file_unrefp) RawImportFile *f = NULL;
- int r;
-
- assert(import);
- assert(raw_url_is_valid(url));
- assert(!local || machine_name_is_valid(local));
-
- if (hashmap_get(import->files, url))
- return -EEXIST;
-
- r = hashmap_ensure_allocated(&import->files, &string_hash_ops);