+ // may be this code can be factored out
+ // together with the autodiscovery of indexes
+ // of addDirJobs
+ if ( ( _options & AutoAddChecksumsIndexes ) ||
+ ( _options & AutoAddContentFileIndexes ) )
+ {
+ // if auto indexing is enabled, then we need to read the
+ // index for each file. We look only in the directory
+ // where the file is. this is expensive of course.
+ filesystem::DirContent content;
+ getDirectoryContent(media, (*it_res)->location.filename().dirname(), content);
+ // this method test for the option flags so indexes are added
+ // only if the options are enabled
+ MIL << "Autodiscovering signed indexes on '"
+ << (*it_res)->location.filename().dirname() << "' for '"
+ << (*it_res)->location.filename() << "'" << endl;
+
+ autoaddIndexes(content, media, (*it_res)->location.filename().dirname(), dest_dir);
+
+ // also look in the root of the media
+ content.clear();
+ getDirectoryContent(media, Pathname("/"), content);
+ // this method test for the option flags so indexes are added
+ // only if the options are enabled
+ MIL << "Autodiscovering signed indexes on '"
+ << "/" << "' for '"
+ << (*it_res)->location.filename() << "'" << endl;
+
+ autoaddIndexes(content, media, Pathname("/"), dest_dir);
+ }
+
+ provideToDest(media, (*it_res)->location, dest_dir, (*it_res)->deltafile);
+
+ // if the file was not transfered, and no exception, just
+ // return, as it was an optional file
+ if ( ! PathInfo(dest_dir + (*it_res)->location.filename()).isExist() )
+ return;
+
+ // if the checksum is empty, but the checksum is in one of the
+ // indexes checksum, then add a checker
+ if ( (*it_res)->location.checksum().empty() )
+ {
+ if ( _checksums.find((*it_res)->location.filename().asString())
+ != _checksums.end() )
+ {
+ CheckSum chksm = _checksums[(*it_res)->location.filename().asString()];
+ ChecksumFileChecker digest_check(chksm);
+ (*it_res)->checkers.push_back(digest_check);
+ }
+ else
+ {
+ // if the index checksum is empty too, we only add the checker
+ // if the AlwaysVerifyChecksum option is set on
+ if ( (*it_res)->flags & FetcherJob::AlwaysVerifyChecksum )
+ {
+ // add the checker with the empty checksum
+ ChecksumFileChecker digest_check((*it_res)->location.checksum());
+ (*it_res)->checkers.push_back(digest_check);
+ }
+ }
+ }
+ else
+ {
+ // checksum is not empty, so add a checksum checker
+ ChecksumFileChecker digest_check((*it_res)->location.checksum());
+ (*it_res)->checkers.push_back(digest_check);
+ }