#include <Fetcher.h>
Classes | |
class | Impl |
Fetcher implementation. More... | |
Public Types | |
enum | Option { AutoAddContentFileIndexes = 0x0001, AutoAddSha1sumsIndexes = 0x0002, AutoAddIndexes = 0x0001 | 0x0002 } |
Various option flags to change behavior. More... | |
Public Member Functions | |
ZYPP_DECLARE_FLAGS (Options, Option) | |
Fetcher () | |
Default ctor. | |
virtual | ~Fetcher () |
Dtor. | |
void | setOptions (Options options) |
Set the Fetcher options. | |
Options | options () const |
Get current options. | |
void | addIndex (const OnMediaLocation &resource) |
Adds an index containing metadata (for example checksums ) that will be retrieved and read before the job processing starts. | |
void | enqueue (const OnMediaLocation &resource, const FileChecker &checker=FileChecker()) |
Enqueue a object for transferal, they will not be transfered until start() is called. | |
void | enqueueDigested (const OnMediaLocation &resource, const FileChecker &checker=FileChecker()) |
Enqueue a object for transferal, they will not be transfered until start() is called. | |
void | enqueueDir (const OnMediaLocation &resource, bool recursive=false, const FileChecker &checker=FileChecker()) |
Enqueue a directory. | |
void | enqueueDigestedDir (const OnMediaLocation &resource, bool recursive=false, const FileChecker &checker=FileChecker()) |
Enqueue a directory and always check for checksums. | |
void | addCachePath (const Pathname &cache_dir) |
adds a directory to the list of directories where to look for cached files | |
void | reset () |
Reset the transfer (jobs) list. | |
void | start (const Pathname &dest_dir, MediaSetAccess &media, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc()) |
start the transfer to a destination directory dest_dir You have to provde a media set access media to get the files from The file tree will be replicated inside this directory | |
Private Attributes | |
RWCOW_pointer< Impl > | _pimpl |
Pointer to implementation. | |
Friends | |
std::ostream & | operator<< (std::ostream &str, const Fetcher &obj) |
MediaSetAccess access(url, path); Fetcher fetcher; fetcher.enqueue( OnMediaLocation().setLocation("/somefile") ); fetcher.addCachePath("/tmp/cache") fetcher.start( "/download-dir, access ); fetcher.reset();
To use the checkers. just create a functor implementing bool operator()(const Pathname &file)
ChecksumFileChecker checker(CheckSum("sha1", "...."); fetcher.enqueue( location, checker);
If you need to use more than one checker
location.setChecksum(CheckSum("sha1", "....")); fetcher.enqueueDigested(location);
MediaSetAccess access(url, path); Fetcher fetcher; fetcher.addIndex(OnMediaLocation("/content")); fetcher.enqueue( OnMediaLocation().setLocation("/somefile") ); fetcher.start( "/download-dir, access ); fetcher.reset();
Indexes are supported in SHA1SUMS format (simple text file) with sha1sums and file name, or content file, whith HASH SHA1 line entries.
Definition at line 98 of file Fetcher.h.
zypp::Fetcher::Fetcher | ( | ) |
zypp::Fetcher::~Fetcher | ( | ) | [virtual] |
zypp::Fetcher::ZYPP_DECLARE_FLAGS | ( | Options | , | |
Option | ||||
) |
void zypp::Fetcher::setOptions | ( | Options | options | ) |
Fetcher::Options zypp::Fetcher::options | ( | ) | const |
Get current options.
Definition at line 858 of file Fetcher.cc.
References _pimpl.
void zypp::Fetcher::addIndex | ( | const OnMediaLocation & | resource | ) |
Adds an index containing metadata (for example checksums ) that will be retrieved and read before the job processing starts.
Nothing will be transfered or checked until start() is called.
The index is relative to the media path, and the listed files too.
Indexes in the SHA1SUM format, and YaST content file
The file has to be signed or the user will be warned that the file is unsigned. You can place the signature next to the file adding the .asc extension.
If you expect the key to not to be in the target system, then you can place it next to the index using adding the .key extension.
Definition at line 883 of file Fetcher.cc.
References _pimpl.
void zypp::Fetcher::enqueue | ( | const OnMediaLocation & | resource, | |
const FileChecker & | checker = FileChecker() | |||
) |
Enqueue a object for transferal, they will not be transfered until start() is called.
Definition at line 889 of file Fetcher.cc.
References _pimpl.
Referenced by zypp::repo::yum::Downloader::download(), zypp::repo::susetags::Downloader::download(), zypp::Fetcher::Impl::downloadIndex(), zypp::repo::downloadMediaInfo(), and zypp::repo::RepoMediaAccess::provideFile().
void zypp::Fetcher::enqueueDigested | ( | const OnMediaLocation & | resource, | |
const FileChecker & | checker = FileChecker() | |||
) |
Enqueue a object for transferal, they will not be transfered until start() is called.
Definition at line 863 of file Fetcher.cc.
References _pimpl.
Referenced by zypp::repo::susetags::Downloader::download(), and zypp::repo::yum::Downloader::repomd_Callback().
void zypp::Fetcher::enqueueDir | ( | const OnMediaLocation & | resource, | |
bool | recursive = false , |
|||
const FileChecker & | checker = FileChecker() | |||
) |
Enqueue a directory.
As the files to be enqueued are not known in advance, all files whose checksum can be found in some index are enqueued with checksum checking. Otherwise they are not.
Some index may provide the checksums, either by addIndex or using AutoAddIndexes flag.
Files are checked by providing a SHA1SUMS or content file listing <checksum> filename and a respective SHA1SUMS.asc/content.asc which has the signature for the checksums.
If you expect the user to not have the key of the signature either in the trusted or untrusted keyring, you can offer it as SHA1SUMS.key (or content.key)
recursive | True if the complete tree should be enqueued. |
The format of the file SHA1SUMS is the output of: ls | grep -v SHA1SUMS | xargs sha1sum > SHA1SUMS in each subdirectory.
Every file SHA1SUMS.* except of SHA1SUMS.(asc|key|(void)) will not be transfered and will be ignored.
Definition at line 868 of file Fetcher.cc.
References _pimpl.
void zypp::Fetcher::enqueueDigestedDir | ( | const OnMediaLocation & | resource, | |
bool | recursive = false , |
|||
const FileChecker & | checker = FileChecker() | |||
) |
Enqueue a directory and always check for checksums.
As the files to be enqueued are not known in advance, all files are enqueued with checksum checking. If the checksum of some file is not in some index, then there will be a verification warning ( DigestReport ).
Therefore some index will need to provide the checksums, either by addIndex or using AutoAddIndexes flag.
Files are checked by providing a SHA1SUMS or content file listing <checksum> filename and a respective SHA1SUMS.asc/content.asc which has the signature for the checksums.
If you expect the user to not have the key of the signature either in the trusted or untrusted keyring, you can offer it as SHA1SUMS.key (or content.key)
recursive | True if the complete tree should be enqueued. |
The format of the file SHA1SUMS is the output of: ls | grep -v SHA1SUMS | xargs sha1sum > SHA1SUMS in each subdirectory.
Every file SHA1SUMS.* except of SHA1SUMS.(asc|key|(void)) will not be transfered and will be ignored.
Definition at line 875 of file Fetcher.cc.
References _pimpl.
void zypp::Fetcher::addCachePath | ( | const Pathname & | cache_dir | ) |
adds a directory to the list of directories where to look for cached files
Definition at line 894 of file Fetcher.cc.
References _pimpl.
Referenced by zypp::repo::RepoMediaAccess::provideFile().
void zypp::Fetcher::reset | ( | ) |
Reset the transfer (jobs) list.
Definition at line 899 of file Fetcher.cc.
References _pimpl, and zypp::RWCOW_pointer< _D, _Traits >::reset().
Referenced by zypp::repo::yum::Downloader::download(), zypp::repo::susetags::Downloader::download(), zypp::Fetcher::Impl::downloadIndex(), and zypp::repo::downloadMediaInfo().
void zypp::Fetcher::start | ( | const Pathname & | dest_dir, | |
MediaSetAccess & | media, | |||
const ProgressData::ReceiverFnc & | progress = ProgressData::ReceiverFnc() | |||
) |
start the transfer to a destination directory dest_dir You have to provde a media set access media to get the files from The file tree will be replicated inside this directory
Definition at line 904 of file Fetcher.cc.
References _pimpl.
Referenced by zypp::repo::yum::Downloader::download(), zypp::repo::susetags::Downloader::download(), zypp::Fetcher::Impl::downloadIndex(), zypp::repo::downloadMediaInfo(), zypp::repo::RepoMediaAccess::provideFile(), and zypp::repo::yum::Downloader::repomd_Callback().
std::ostream & operator<< | ( | std::ostream & | str, | |
const Fetcher & | obj | |||
) | [friend] |
Stream output
Definition at line 911 of file Fetcher.cc.
RWCOW_pointer<Impl> zypp::Fetcher::_pimpl [private] |
Pointer to implementation.
Definition at line 312 of file Fetcher.h.
Referenced by addCachePath(), addIndex(), enqueue(), enqueueDigested(), enqueueDigestedDir(), enqueueDir(), zypp::operator<<(), options(), reset(), and start().