Exemplo n.º 1
0
 /**
  * Does not account (i.e. includes) for skipped files.
  *
  * @return number of pieces still needed (magnet mode or not), or -1 if unknown
  * @since 0.8.4
  */
 public long getNeeded() {
   if (storage != null) return storage.needed();
   if (meta != null)
     // FIXME subtract chunks we have
     return meta.getTotalLength();
   // FIXME fake
   return -1;
 }
Exemplo n.º 2
0
 /**
  * Bytes not yet in storage. Does NOT account for skipped files.
  *
  * @return exact value. or -1 if no storage yet. getNeeded() * pieceLength(0) isn't accurate if
  *     last piece is still needed.
  * @since 0.8.9
  */
 public long getRemainingLength() {
   if (meta != null && storage != null) {
     long needed = storage.needed();
     long length0 = meta.getPieceLength(0);
     long remaining = needed * length0;
     // fixup if last piece is needed
     int last = meta.getPieces() - 1;
     if (last != 0 && !storage.getBitField().get(last))
       remaining -= length0 - meta.getPieceLength(last);
     return remaining;
   }
   return -1;
 }