/* download_manifests() * Description: To search Clear bundles for a particular entry, a complete set of * manifests must be downloaded. This function does so, asynchronously, using * the curl_multi interface */ int download_manifests(struct manifest **MoM) { struct list *list; struct file *file; char *tarfile, *untard_file, *url; struct manifest *subMan = NULL; int current_version; int ret = 0; double size; current_version = read_version_from_subvol_file(path_prefix); swupd_curl_set_current_version(current_version); ret = load_manifests(current_version, current_version, "MoM", NULL, MoM); if (ret != 0) { printf("Cannot load official manifest MoM for version %i\n", current_version); return ret; } subscription_versions_from_MoM(*MoM, 0); list = (*MoM)->manifests; size = query_total_download_size(list); if (size == -1) { printf("Downloading manifests. Expect a delay, up to 100MB may be downloaded\n"); } else if (size > 0) { printf("Downloading Clear Linux manifests\n"); printf(" %.2f MB total...\n\n", size); } while (list) { file = list->data; list = list->next; create_and_append_subscription(file->filename); string_or_die(&untard_file, "%s/%i/Manifest.%s", STATE_DIR, file->last_change, file->filename); string_or_die(&tarfile, "%s/%i/Manifest.%s.tar", STATE_DIR, file->last_change, file->filename); if (access(untard_file, F_OK) == -1) { /* Do download */ printf(" '%s' manifest...\n", file->filename); ret = load_manifests(current_version, file->last_change, file->filename, NULL, &subMan); if (ret != 0) { printf("Cannot load official manifest MoM for version %i\n", current_version); } free_manifest(subMan); } if (access(untard_file, F_OK) == -1) { string_or_die(&url, "%s/%i/Manifest.%s.tar", preferred_content_url, current_version, file->filename); printf("Error: Failure reading from %s\n", url); free(url); } unlink(tarfile); free(untard_file); free(tarfile); } return ret; }
/* download_manifests() * Description: To search Clear bundles for a particular entry, a complete set of * manifests must be downloaded. This function does so, asynchronously, using * the curl_multi interface */ static int download_manifests(struct manifest **MoM, struct list **subs) { struct list *list = NULL; struct file *file = NULL; char *tarfile, *untard_file, *url = NULL; struct manifest *subMan = NULL; int current_version; int ret = 0; double size; bool did_download = false; current_version = get_current_version(path_prefix); if (current_version < 0) { fprintf(stderr, "Error: Unable to determine current OS version\n"); return ECURRENT_VERSION; } *MoM = load_mom(current_version, false, false, NULL); if (!(*MoM)) { fprintf(stderr, "Cannot load official manifest MoM for version %i\n", current_version); return EMOM_LOAD; } list = (*MoM)->manifests; size = query_total_download_size(list); if (size == -1) { fprintf(stderr, "Downloading manifests. Expect a delay, up to 100MB may be downloaded\n"); } else if (size > 0) { fprintf(stderr, "Downloading Clear Linux manifests\n"); fprintf(stderr, " %.2f MB total...\n\n", size); } while (list) { file = list->data; list = list->next; create_and_append_subscription(subs, file->filename); string_or_die(&untard_file, "%s/%i/Manifest.%s", state_dir, file->last_change, file->filename); string_or_die(&tarfile, "%s/%i/Manifest.%s.tar", state_dir, file->last_change, file->filename); if (access(untard_file, F_OK) == -1) { /* Do download */ subMan = load_manifest(file->last_change, file, *MoM, false); if (!subMan) { fprintf(stderr, "Cannot load official manifest MoM for version %i\n", current_version); } else { did_download = true; } free_manifest(subMan); } if (access(untard_file, F_OK) == -1) { string_or_die(&url, "%s/%i/Manifest.%s.tar", content_url, current_version, file->filename); fprintf(stderr, "Error: Failure reading from %s\n", url); free_string(&url); } unlink(tarfile); free_string(&untard_file); free_string(&tarfile); } if (did_download) { fprintf(stderr, "Completed manifests download.\n\n"); } return ret; }