Exemplo n.º 1
0
 /**
  * Finds a file that is not being serviced by a download worker and starts to download it.
  *
  * @return true iff there was a file in the queue to consider, false otherwise.
  */
 private synchronized boolean dispatchFile() {
   // 1) establish the active directory:
   DownloadFile nF = controller.q.getInactiveDownloadFile();
   if (nF != null) {
     // Logger.log("attempting to dispatch: "+nF);
     // start it downloading...
     // 1) find a source for the download:
     Map<String, DownloadSource> sources =
         controller.ssvr.getIndexNodeCommunicator().getSourcesForFile(nF.hash);
     if (sources.isEmpty()) {
       nF.notifyNoSources();
     } else {
       startFileDownloading(nF, controller.peerstats.getBestSource(sources));
     }
     return true;
   } else {
     // Logger.log("Nothing to dispatch.");
     return false;
   }
 }