Loading...
Searching...
No Matches
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)
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)
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)
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)
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

## lr_download_simple

#define lr_download_simple | ( |  | handle,
|  |  | relative_url,
|  |  | err )

Value:
lr_download_package((handle), (relative_url), NULL, 0, \
NULL, 0, NULL, 0, (err))
lr_download_package
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

  handle | Librepo handle.
  relative_url | Relative part of url.
  err | GError **

Returns
  See lr_download_package

Definition at line 43 of file package_downloader.h.

## Enumeration Type Documentation

## LrPackageCheckFlag

enum LrPackageCheckFlag

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 278 of file package_downloader.h.

## LrPackageDownloadFlag

enum LrPackageDownloadFlag

Available flags for package downloader

Enumerator

LR_PACKAGEDOWNLOAD_FAILFAST

If TRUE, then whole downloading is stopped 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 255 of file package_downloader.h.

## Function Documentation

## lr_check_packages()

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.

## lr_download_package()

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 already exists and checksum matches, then no downloading is done and LRE_ALREADYDOWNLOADED return code is returned.

Parameters

  handle | Librepo handle.
  relative_url | Relative part of url.
  dest | Destination file, directory or NULL (current working dir is used).
  checksum_type | Type of checksum.
  checksum | Checksum value or NULL.
  expectedsize | Expected size of target. If >0 and server reports different size, then no download is performed.
  base_url | If specified, mirrors from handle are ignored and this base_url is used for downloading.
  resume | If TRUE try to resume downloading if dest file already exists.
  err | GError **

Returns
  TRUE if everything is ok, FALSE if err is set.

## lr_download_packages()

gboolean lr_download_packages | ( | GSList * | targets,
|  | LrPackageDownloadFlag | flags,
|  | GError ** | err )

Download all LrPackageTargets at the targets GSList.

Parameters

  targets | GSList where each element is a LrPackageTarget object
  flags | Bitfield with flags to download
  err | GError **

Returns
  If FALSE then err is set.

## lr_packagetarget_free()

void lr_packagetarget_free | ( | LrPackageTarget * | target | ) |

Free LrPackageTarget object.

Parameters

  target | LrPackageTarget object

## lr_packagetarget_new()

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

  handle | Handle related to this download or NULL.
  relative_url | Relative part of URL to download. First part of URL will be picked from the LrHandle (LRO_URL or mirror) during download process or base_url will be used if it is specified. It is expected to already come URL-encoded.
  dest | Destination 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_type | Type of checksum or LR_CHECKSUM_UNKNOWN.
  checksum | Expected checksum value or NULL.
  base_url | Base URL or NULL
  expectedsize | Expected size of the target. If server reports different size, then download won't be performed.
  resume | If TRUE, then downloader will try to resume download if the destination file exists. If the file doesn't exist it will be downloaded.
  progresscb | Progress callback for this transfer.
  cbdata | User data for the callback
  err | GError **

Returns
  Newly allocated LrPackageTarget or NULL on error

## lr_packagetarget_new_v2()

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

  handle | Handle related to this download or NULL.
  relative_url | Relative part of URL to download. First part of URL will be picked from the LrHandle (LRO_URL or mirror) during download process or base_url will be used if it is specified.
  dest | Destination 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_type | Type of checksum or LR_CHECKSUM_UNKNOWN.
  checksum | Expected checksum value or NULL.
  base_url | Base URL or NULL
  expectedsize | Expected size of the target. If server reports different size, then no download is performed. If 0 then size check is ignored.
  resume | If TRUE, then downloader try to resume download if destination file exists. If the file doesn't exists, it will be normally downloaded again.
  progresscb | Progress callback for this transfer.
  cbdata | User data for the callbacks
  endcb | Callback called when target transfer is done. (Use status to check if successfully
  mirrorfailurecb | Called when download from a mirror failed.
  err | GError **

Returns
  Newly allocated LrPackageTarget or NULL on error

## lr_packagetarget_new_v3()

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

  byterangestart | Download 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.
  byterangeend | Download 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