Librepo library  1.7.13
C library for downloading linux repository metadata and packages
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules
Package downloading

Data Structures

struct  LrPackageTarget
 

Macros

#define lr_download_simple(handle, relative_url, err)
 

Enumerations

enum  LrPackageDownloadFlag { LR_PACKAGEDOWNLOAD_FAILFAST = 1 << 0 }
 
enum  LrPackageCheckFlag { LR_PACKAGECHECK_FAILFAST = 1 << 0 }
 

Functions

gboolean lr_download_package (LrHandle *handle, const char *relative_url, const char *dest, LrChecksumType checksum_type, const char *checksum, gint64 expectedsize, const char *base_url, gboolean resume, GError **err)
 
LrPackageTargetlr_packagetarget_new (LrHandle *handle, const char *relative_url, const char *dest, LrChecksumType checksum_type, const char *checksum, gint64 expectedsize, const char *base_url, gboolean resume, LrProgressCb progresscb, void *cbdata, GError **err)
 
LrPackageTargetlr_packagetarget_new_v2 (LrHandle *handle, const char *relative_url, const char *dest, LrChecksumType checksum_type, const char *checksum, gint64 expectedsize, const char *base_url, gboolean resume, LrProgressCb progresscb, void *cbdata, LrEndCb endcb, LrMirrorFailureCb mirrorfailurecb, GError **err)
 
LrPackageTargetlr_packagetarget_new_v3 (LrHandle *handle, const char *relative_url, const char *dest, LrChecksumType checksum_type, const char *checksum, gint64 expectedsize, const char *base_url, gboolean resume, LrProgressCb progresscb, void *cbdata, LrEndCb endcb, LrMirrorFailureCb mirrorfailurecb, gint64 byterangestart, gint64 byterangeend, GError **err)
 
void lr_packagetarget_free (LrPackageTarget *target)
 
gboolean lr_download_packages (GSList *targets, LrPackageDownloadFlag flags, GError **err)
 
gboolean lr_check_packages (GSList *targets, LrPackageCheckFlag flags, GError **err)
 

Detailed Description

Macro Definition Documentation

#define lr_download_simple (   handle,
  relative_url,
  err 
)
Value:
lr_download_package((handle), (relative_url), NULL, 0, \
NULL, 0, NULL, 0, (err))
gboolean lr_download_package(LrHandle *handle, const char *relative_url, const char *dest, LrChecksumType checksum_type, const char *checksum, gint64 expectedsize, const char *base_url, gboolean resume, GError **err)

Download package from repository.

Parameters
handleLibrepo handle.
relative_urlRelative part of url.
errGError **
Returns
See lr_download_package

Definition at line 43 of file package_downloader.h.

Enumeration Type Documentation

Enumerator
LR_PACKAGECHECK_FAILFAST 

If TRUE, then whole check is stoped immediately when any of target doesn't exist locally or its checksum doesn't match. (FALSE is returned and err is set). If the failfast is FALSE, then this function returns after check of all targets is finished (no matter if successfully or unsuccessfully) and FALSE is returned only if a nonrecoverable error related to the function itself is meet (Errors related to individual targets are reported via corresponding PackageTarget objects).

Definition at line 277 of file package_downloader.h.

Available flags for package downloader

Enumerator
LR_PACKAGEDOWNLOAD_FAILFAST 

If TRUE, then whole downloading is stoped immediately when any of download fails (FALSE is returned and err is set). If the failfast is FALSE, then this function returns after all downloads finish (no matter if successfully or unsuccessfully) and FALSE is returned only if a nonrecoverable error related to the function itself is meet (Errors related to individual downloads are reported via corresponding PackageTarget objects).

Definition at line 254 of file package_downloader.h.

Function Documentation

gboolean lr_check_packages ( GSList *  targets,
LrPackageCheckFlag  flags,
GError **  err 
)

Check if targets locally exist and checksums match. If target locally exists, then its err is NULL, if it doesn't exists, or checksum is differ. Then target->err is an error message.

gboolean lr_download_package ( LrHandle handle,
const char *  relative_url,
const char *  dest,
LrChecksumType  checksum_type,
const char *  checksum,
gint64  expectedsize,
const char *  base_url,
gboolean  resume,
GError **  err 
)

Download package from repository or base_url. Note: If resume, checksum and checksum_type are specified and the downloaded package alredy exists and checksum matches, then no downloading is done and LRE_ALREADYDOWNLOADED return code is returned.

Parameters
handleLibrepo handle.
relative_urlRelative part of url.
destDestination file, directory or NULL (current working dir is used).
checksum_typeType of checksum.
checksumChecksum value or NULL.
expectedsizeExpected size of target. If >0 and server reports different size, then no download is performed.
base_urlIf specified, mirrors from handle are ignored and this base_url is used for downloading.
resumeIf TRUE try to resume downloading if dest file already exists.
errGError **
Returns
TRUE if everything is ok, FALSE if err is set.
gboolean lr_download_packages ( GSList *  targets,
LrPackageDownloadFlag  flags,
GError **  err 
)

Download all LrPackageTargets at the targets GSList.

Parameters
targetsGSList where each element is a LrPackageTarget object
flagsBitfield with flags to download
errGError **
Returns
If FALSE then err is set.
void lr_packagetarget_free ( LrPackageTarget target)

Free LrPackageTarget object.

Parameters
targetLrPackageTarget object
LrPackageTarget* lr_packagetarget_new ( LrHandle handle,
const char *  relative_url,
const char *  dest,
LrChecksumType  checksum_type,
const char *  checksum,
gint64  expectedsize,
const char *  base_url,
gboolean  resume,
LrProgressCb  progresscb,
void *  cbdata,
GError **  err 
)

Create new LrPackageTarget object.

Parameters
handleHandle related to this download or NULL.
relative_urlRelative part of URL to download. First part of URL will be picked from the LrHandle (LRO_URL or mirror) during download proccess or base_url will be used if it is specified.
destDestination filename or just directory (filename itself will be derived from the relative_url) or NULL (current working directory + filename derived from relative_url will be used).
checksum_typeType of checksum or LR_CHECKSUM_UNKNOWN.
checksumExpected checksum value or NULL.
base_urlBase URL or NULL
expectedsizeExpected size of the target. If server reports different size, then download won't be performed.
resumeIf TRUE, then downloader will try to resume download if the destination file exists. If the file doesn't exist it will be downloaded.
progresscbProgress callback for this transfer.
cbdataUser data for the callback
errGError **
Returns
Newly allocated LrPackageTarget or NULL on error
LrPackageTarget* lr_packagetarget_new_v2 ( LrHandle handle,
const char *  relative_url,
const char *  dest,
LrChecksumType  checksum_type,
const char *  checksum,
gint64  expectedsize,
const char *  base_url,
gboolean  resume,
LrProgressCb  progresscb,
void *  cbdata,
LrEndCb  endcb,
LrMirrorFailureCb  mirrorfailurecb,
GError **  err 
)

Create new LrPackageTarget object. Almost same as lr_packagetarget_new() except this function could set more callbacks.

Parameters
handleHandle related to this download or NULL.
relative_urlRelative part of URL to download. First part of URL will be picked from the LrHandle (LRO_URL or mirror) during download proccess or base_url will be used if it is specified.
destDestination filename or just directory (filename itself will be derived from the relative_url) or NULL (current working directory + filename derived from relative_url will be used).
checksum_typeType of checksum or LR_CHECKSUM_UNKNOWN.
checksumExpected checksum value or NULL.
base_urlBase URL or NULL
expectedsizeExpected size of the target. If server reports different size, then no download is performed. If 0 then size check is ignored.
resumeIf TRUE, then downloader try to resume download if destination file exists. If the file doesn't exists, it will be normally downloaded again.
progresscbProgress callback for this transfer.
cbdataUser data for the callbacks
endcbCallback called when target transfer is done. (Use status to check if successfully
mirrorfailurecbCalled when download from a mirror failed.
errGError **
Returns
Newly allocated LrPackageTarget or NULL on error
LrPackageTarget* lr_packagetarget_new_v3 ( LrHandle handle,
const char *  relative_url,
const char *  dest,
LrChecksumType  checksum_type,
const char *  checksum,
gint64  expectedsize,
const char *  base_url,
gboolean  resume,
LrProgressCb  progresscb,
void *  cbdata,
LrEndCb  endcb,
LrMirrorFailureCb  mirrorfailurecb,
gint64  byterangestart,
gint64  byterangeend,
GError **  err 
)

Create new LrPackageTarget object. Almost same as lr_packagetarget_new_v2() except this function could set a required byte range of the package. For params see lr_packagetarget_new_v2().

Parameters
byterangestartDownload only specified range of bytes. This param specifies the begin. 0 is default. Note: When this options is != 0 then resume must be disabled - resume param must be FALSE.
byterangeendDownload only specified range of bytes. This param specifies the end. 0 is default. If this value is less or equal to byterangestart, then it is ignored.
Returns
Newly allocated LrPackageTarget or NULL on error