libzypp 17.37.10

MediaInfoDownloader.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
10#include <fstream>
11#include <zypp/base/String.h>
12#include <zypp/base/Logger.h>
13#include <zypp/base/Function.h>
14
15#include "MediaInfoDownloader.h"
16#include <zypp-core/base/UserRequestException>
17
18
19 namespace zypp
20{
21 namespace repo
22{
23
24 void downloadMediaInfo( const Pathname &dest_dir,
25 MediaSetAccess &media,
26 const ProgressData::ReceiverFnc & progressrcv )
27{
28 Fetcher fetcher;
29
30 //hardcode the max filesize to 20MB, to prevent unlimited data downloads but this limit will
31 //never be reached in a sane setup
32 fetcher.enqueue( OnMediaLocation("/media.1/media").setOptional(true).setDownloadSize( ByteCount(20, ByteCount::MB ) ).setMirrorsAllowed(false) );
33 fetcher.start( dest_dir, media, progressrcv );
34 // ready, go!
35 fetcher.reset();
36}
37
38}// ns repo
39} // ns zypp
40
41
42
MediaInfoDownloader.h
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::ByteCount::MB
static const Unit MB
1000^2 Byte
Definition ByteCount.h:61
zypp::Fetcher
This class allows to retrieve a group of files in a confortable way, providing some smartness that do...
Definition Fetcher.h:104
zypp::Fetcher::start
void start(const Pathname &dest_dir, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
start the transfer to a destination directory dest_dir The media has to be provides with setMediaSetA...
Definition Fetcher.cc:927
zypp::Fetcher::reset
void reset()
Reset the transfer (jobs) list.
Definition Fetcher.cc:917
zypp::Fetcher::enqueue
void enqueue(const OnMediaLocation &resource, const FileChecker &checker=FileChecker())
Enqueue a object for transferal, they will not be transferred until start() is called.
Definition Fetcher.cc:901
zypp::MediaSetAccess
Media access layer responsible for handling files distributed on a set of media with media change and...
Definition MediaSetAccess.h:82
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition onmedialocation.h:37
zypp::ProgressData::ReceiverFnc
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition progressdata.h:140
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::repo
Definition DeltaCandidates.cc:30
zypp::repo::downloadMediaInfo
void downloadMediaInfo(const Pathname &dest_dir, MediaSetAccess &media, const ProgressData::ReceiverFnc &progressrcv)
Downloads the media info (/media.1) to a local directory.
Definition MediaInfoDownloader.cc:24
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
Function.h
Logger.h
String.h