3 #include "zypp/base/String.h"
4 #include "zypp/OnMediaLocation.h"
5 #include "zypp/MediaSetAccess.h"
6 #include "zypp/Fetcher.h"
7 #include "zypp/repo/MediaInfoDownloader.h"
9 #include "zypp/repo/susetags/Downloader.h"
10 #include "zypp/base/UserRequestException.h"
21 Downloader::Downloader(const Pathname &path )
27 RepoStatus Downloader::status( MediaSetAccess &media )
29 Pathname content = media.provideFile( _path + "/content");
30 return RepoStatus(content);
33 void Downloader::download( MediaSetAccess &media,
34 const Pathname &dest_dir,
35 const ProgressData::ReceiverFnc & progress )
37 downloadMediaInfo( dest_dir, media );
39 SignatureFileChecker sigchecker;
41 Pathname sig = _path + "/content.asc";
42 if ( media.doesFileExist(sig) )
44 this->enqueue( OnMediaLocation( sig, 1 ) );
45 this->start( dest_dir, media );
48 sigchecker = SignatureFileChecker( dest_dir + sig );
51 Pathname key = _path + "/content.key";
52 if ( media.doesFileExist(key) )
54 this->enqueue( OnMediaLocation( key, 1 ) );
55 this->start( dest_dir, media );
57 sigchecker.addPublicKey(dest_dir + key);
61 this->enqueue( OnMediaLocation( _path + "/content", 1 ), sigchecker );
62 this->start( dest_dir, media );
65 std::ifstream file((dest_dir + _path + "/content").asString().c_str());
69 // FIXME Note this code assumes DESCR comes before as META
71 while (file && !file.eof())
73 getline(file, buffer);
74 if ( buffer.substr( 0, 5 ) == "DESCR" )
76 std::vector<std::string> words;
77 if ( str::split( buffer, std::back_inserter(words) ) != 2 )
80 ZYPP_THROW(Exception("bad DESCR line"));
84 else if ( buffer.substr( 0, 4 ) == "META" )
86 std::vector<std::string> words;
87 if ( str::split( buffer, std::back_inserter(words) ) != 4 )
90 ZYPP_THROW(Exception("bad META line"));
92 OnMediaLocation location( _path + descr_dir + words[3], 1 );
93 location.setChecksum( CheckSum( words[1], words[2] ) );
94 this->enqueueDigested(location);
96 else if (buffer.substr( 0, 3 ) == "KEY")
98 std::vector<std::string> words;
99 if ( str::split( buffer, std::back_inserter(words) ) != 4 )
102 ZYPP_THROW(Exception("bad KEY line"));
104 OnMediaLocation location( _path + words[3], 1 );
105 location.setChecksum( CheckSum( words[1], words[2] ) );
106 this->enqueueDigested(location);
110 this->start( dest_dir, media );