private long downloadIndexFiles(boolean downloadCompleteIndex,Directory indexDir,Directory tmpIndexDir,long latestGeneration) throws Exception {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Download files to dir: " + Arrays.asList(indexDir.listAll()));
  }
  long bytesDownloaded=0;
  for (  Map<String,Object> file : filesToDownload) {
    String filename=(String)file.get(NAME);
    long size=(Long)file.get(SIZE);
    CompareResult compareResult=compareFile(indexDir,filename,size,(Long)file.get(CHECKSUM));
    if (!compareResult.equal || downloadCompleteIndex || filesToAlwaysDownloadIfNoChecksums(filename,size,compareResult)) {
      dirFileFetcher=new DirectoryFileFetcher(tmpIndexDir,file,(String)file.get(NAME),FILE,latestGeneration);
      currentFile=file;
      dirFileFetcher.fetchFile();
      bytesDownloaded+=dirFileFetcher.getBytesDownloaded();
      filesDownloaded.add(new HashMap<>(file));
    }
 else {
      LOG.info("Skipping download for " + file.get(NAME) + " because it already exists");
    }
  }
  return bytesDownloaded;
}

private long downloadIndexFiles ( boolean downloadCompleteIndex , Directory indexDir , Directory tmpIndexDir , long latestGeneration ) throws Exception { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Download files to dir: " + Arrays . asList ( indexDir . listAll ( ) ) ) ; } long bytesDownloaded = 0 ; for ( Map < String , Object > file : filesToDownload ) { String filename = ( String ) file . get ( NAME ) ; long size = ( Long ) file . get ( SIZE ) ; CompareResult compareResult = compareFile ( indexDir , filename , size , ( Long ) file . get ( CHECKSUM ) ) ; if ( ! compareResult . equal || downloadCompleteIndex || filesToAlwaysDownloadIfNoChecksums ( filename , size , compareResult ) ) { dirFileFetcher = new DirectoryFileFetcher ( tmpIndexDir , file , ( String ) file . get ( NAME ) , FILE , latestGeneration ) ; currentFile = file ; dirFileFetcher . fetchFile ( ) ; bytesDownloaded += dirFileFetcher . getBytesDownloaded ( ) ; filesDownloaded . add ( new HashMap < > ( file ) ) ; } else { LOG . info ( "Skipping download for " + file . get ( NAME ) + " because it already exists" ) ; } } return bytesDownloaded ; }
download the index files . if a new index is needed , download all the files .
