예제 #1
0
 public void startDownload() throws IOException {
   startedAt = System.currentTimeMillis();
   manager.getNetMan().sendToAllFriends(new GetBlockMask(root));
   if (fd == null) {
     setState(State.LOADING_FD);
   } else {
     setState(State.DOWNLOADING);
   }
 }
예제 #2
0
  public void fileDescriptorReceived(DownloadConnection source, FileDescriptor fd)
      throws IOException {
    if (this.fd != null) {
      if (T.t) {
        T.info("Already has FD. Ignore the new one and start download for this connection.");
      }
      if (T.t) {
        T.ass(source.readyToStartDownload(), "Not ready to start download?");
      }
      if (needsMoreDownloadConnections()) {
        source.startDownloadingBlock();
      }
      return;
    }
    if (T.t) {
      T.debug("Received file descriptor " + fd);
    }

    this.fd = fd;
    setState(State.DOWNLOADING);

    ArrayList<DownloadConnection> al = new ArrayList<DownloadConnection>();
    for (DownloadConnection c : connections.values()) {
      al.add(c);
    }
    for (DownloadConnection c : al) {
      if (c.readyToStartDownload() && needsMoreDownloadConnections()) {
        c.startDownloadingBlock();
      }
    }
  }
예제 #3
0
 public boolean checkIfDownloadIsComplete() {
   // may be in a state where the file is being moved into the complete directory - then it's
   // complete by this methods definition, but not complete by the filedatabase definition
   if (fd == null) {
     return false;
   }
   boolean b =
       getManager().getCore().getFileManager().isRecentlyDownloadedOrComplete(fd.getRootHash());
   if (b) {
     setState(State.COMPLETED);
   }
   return b;
 }