1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
7 #include "import-compress.h"
10 typedef struct PullJob PullJob
;
12 typedef void (*PullJobFinished
)(PullJob
*job
);
13 typedef int (*PullJobOpenDisk
)(PullJob
*job
);
14 typedef int (*PullJobHeader
)(PullJob
*job
, const char *header
, size_t sz
);
15 typedef void (*PullJobProgress
)(PullJob
*job
);
16 typedef int (*PullJobNotFound
)(PullJob
*job
, char **ret_new_url
);
18 typedef enum PullJobState
{
20 PULL_JOB_ANALYZING
, /* Still reading into ->payload, to figure out what we have */
21 PULL_JOB_RUNNING
, /* Writing to destination */
25 _PULL_JOB_STATE_INVALID
= -EINVAL
,
28 #define PULL_JOB_IS_COMPLETE(j) (IN_SET((j)->state, PULL_JOB_DONE, PULL_JOB_FAILED))
37 PullJobFinished on_finished
;
38 PullJobOpenDisk on_open_disk
;
39 PullJobHeader on_header
;
40 PullJobProgress on_progress
;
41 PullJobNotFound on_not_found
;
45 struct curl_slist
*request_header
;
51 uint64_t content_length
;
52 uint64_t written_compressed
;
53 uint64_t written_uncompressed
;
55 uint64_t uncompressed_max
;
56 uint64_t compressed_max
;
60 size_t payload_allocated
;
66 ImportCompress compress
;
68 unsigned progress_percent
;
70 usec_t last_status_usec
;
75 gcry_md_hd_t checksum_context
;
80 int pull_job_new(PullJob
**job
, const char *url
, CurlGlue
*glue
, void *userdata
);
81 PullJob
* pull_job_unref(PullJob
*job
);
83 int pull_job_begin(PullJob
*j
);
85 void pull_job_curl_on_finished(CurlGlue
*g
, CURL
*curl
, CURLcode result
);
87 DEFINE_TRIVIAL_CLEANUP_FUNC(PullJob
*, pull_job_unref
);