Imported Upstream version 17.23.5
[platform/upstream/libzypp.git] / zypp / repo / MediaInfoDownloader.cc
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/base/UserRequestException.h>
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 ) ) );
33   fetcher.start( dest_dir, media, progressrcv );
34   // ready, go!
35   fetcher.reset();
36 }
37
38 }// ns repo 
39 } // ns zypp
40
41
42