j->on_finished(j);
}
-static int pull_job_restart(PullJob *j, const char *new_url) {
+int pull_job_restart(PullJob *j, const char *new_url) {
int r;
assert(j);
- assert(new_url);
- r = free_and_strdup(&j->url, new_url);
- if (r < 0)
- return r;
+ /* If an URL is specified we retry the same request, just towards a different URL. If the URL is NULL
+ * then we'll fire the same request again (which is useful if some parameters have been changed) */
+
+ if (new_url) {
+ r = free_and_strdup(&j->url, new_url);
+ if (r < 0)
+ return r;
+ }
j->state = PULL_JOB_INIT;
j->error = 0;
j->etag_exists = false;
j->mtime = 0;
iovec_done(&j->checksum);
- iovec_done(&j->expected_checksum);
- j->expected_content_length = UINT64_MAX;
j->content_type = mfree(j->content_type);
+ if (new_url) {
+ /* Reset expectations if the URL changes */
+ iovec_done(&j->expected_checksum);
+ j->expected_content_length = UINT64_MAX;
+ }
+
curl_glue_remove_and_free(j->glue, j->curl);
j->curl = NULL;
- curl_slist_free_all(j->request_header);
- j->request_header = NULL;
-
import_compress_free(&j->compress);
if (j->checksum_ctx) {
int pull_job_set_accept(PullJob *j, char * const *l);
int pull_job_set_bearer_token(PullJob *j, const char *token);
+int pull_job_restart(PullJob *j, const char *new_url);
+
DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob*, pull_job_unref);