+ ERR << "Invalid checker for '" << localfile << "'" << endl;
+ }
+ }
+
+ }
+ catch ( const FileCheckException &e )
+ {
+ ZYPP_RETHROW(e);
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_RETHROW(e);
+ }
+ catch (...)
+ {
+ ZYPP_THROW(Exception("Unknown error while validating " + resource.filename().asString()));
+ }
+ }
+
+ void Fetcher::Impl::autoaddIndexes( const filesystem::DirContent &content,
+ MediaSetAccess &media,
+ const OnMediaLocation &resource,
+ const Pathname &dest_dir )
+ {
+ auto fnc_addIfInContent( [&]( const std::string & index_r ) -> bool
+ {
+ if ( find( content.begin(), content.end(), filesystem::DirEntry(index_r,filesystem::FT_FILE) ) == content.end() )
+ return false;
+ // add the index of this directory
+ OnMediaLocation indexloc( resource );
+ indexloc.changeFilename( resource.filename() + index_r );
+ addIndex( indexloc );
+ // we need to read it now
+ downloadAndReadIndexList( media, dest_dir );
+ return true;
+ } );
+
+ if ( _options & AutoAddChecksumsIndexes )
+ {
+ fnc_addIfInContent( "CHECKSUMS" ) || fnc_addIfInContent( "SHA1SUMS" );
+ }
+ if ( _options & AutoAddContentFileIndexes )
+ {
+ fnc_addIfInContent( "content" );
+ }
+ }
+
+ void Fetcher::Impl::getDirectoryContent( MediaSetAccess &media,
+ const OnMediaLocation &resource,
+ filesystem::DirContent &content )
+ {
+ if ( _dircontent.find(resource.filename().asString())
+ != _dircontent.end() )
+ {
+ filesystem::DirContent filled(_dircontent[resource.filename().asString()]);
+
+ std::copy(filled.begin(), filled.end(), std::back_inserter(content));
+ }
+ else
+ {
+ filesystem::DirContent tofill;
+ media.dirInfo( tofill,
+ resource.filename(),
+ false /* dots */,
+ resource.medianr());
+ std::copy(tofill.begin(), tofill.end(), std::back_inserter(content));
+ _dircontent[resource.filename().asString()] = tofill;
+ }
+ }
+
+ void Fetcher::Impl::addDirJobs( MediaSetAccess &media,
+ const OnMediaLocation &resource,
+ const Pathname &dest_dir, FetcherJob::Flags flags )
+ {
+ // first get the content of the directory so we can add
+ // individual transfer jobs
+ MIL << "Adding directory " << resource.filename() << endl;
+ filesystem::DirContent content;
+ try {
+ getDirectoryContent(media, resource, content);
+ }
+ catch ( media::MediaFileNotFoundException & exception )
+ {
+ ZYPP_CAUGHT( exception );
+ WAR << "Skiping subtree hidden at " << resource.filename() << endl;
+ return;
+ }
+
+ // this method test for the option flags so indexes are added
+ // only if the options are enabled
+ autoaddIndexes(content, media, resource, dest_dir);
+
+ for ( filesystem::DirContent::const_iterator it = content.begin();
+ it != content.end();
+ ++it )
+ {
+ // skip CHECKSUMS* as they were already retrieved
+ if ( str::hasPrefix(it->name, "CHECKSUMS") || str::hasPrefix(it->name, "SHA1SUMS") )
+ continue;
+
+ Pathname filename = resource.filename() + it->name;
+
+ switch ( it->type )