+
+ void Fetcher::Impl::downloadIndex( MediaSetAccess &media, const OnMediaLocation &resource, const Pathname &dest_dir)
+ {
+ MIL << "downloading index " << resource << endl;
+ // create a new fetcher with a different state to transfer the
+ // file containing checksums and its signature
+ Fetcher fetcher;
+ // signature checker for index. We havent got the signature from
+ // the nextwork yet.
+ SignatureFileChecker sigchecker;
+
+ // build the name of the index and the signature
+ OnMediaLocation idxloc(resource);
+ OnMediaLocation sigloc(resource);
+ OnMediaLocation keyloc(resource);
+
+ // we should not fail the download if those don't exists
+ // the checking will warn later
+ sigloc.setOptional(true);
+ keyloc.setOptional(true);
+
+ // calculate signature and key name
+ sigloc.changeFilename( sigloc.filename().extend(".asc") );
+ keyloc.changeFilename( keyloc.filename().extend(".key") );
+
+ //assert_dir(dest_dir + idxloc.filename().dirname());
+
+ // transfer the signature
+ fetcher.enqueue(sigloc);
+ fetcher.start( dest_dir, media );
+ // if we get the signature, update the checker
+ if ( PathInfo(dest_dir + sigloc.filename()).isExist() )
+ sigchecker = SignatureFileChecker(dest_dir + sigloc.filename());
+
+ fetcher.reset();
+
+ // now the key
+ fetcher.enqueue(keyloc);
+ fetcher.start( dest_dir, media );
+ fetcher.reset();
+
+ // try to import the key
+ if ( PathInfo(dest_dir + keyloc.filename()).isExist() )
+ getZYpp()->keyRing()->importKey(PublicKey(dest_dir + keyloc.filename()), false);
+ else
+ WAR << "No public key specified by user for index '" << keyloc.filename() << "'"<< endl;
+
+ // now the index itself
+ fetcher.enqueue( idxloc, FileChecker(sigchecker) );
+ fetcher.start( dest_dir, media );
+ fetcher.reset();
+ }
+