forked from I2P_Developers/i2p.i2p
* i2psnark: Fix inaccuracy in the completed bytes display
This commit is contained in:
@ -779,6 +779,26 @@ public class Snark
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return number of pieces still needed (magnet mode or not), or -1 if unknown
|
* @return number of pieces still needed (magnet mode or not), or -1 if unknown
|
||||||
* @since 0.8.4
|
* @since 0.8.4
|
||||||
|
@ -765,8 +765,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
long total = snark.getTotalLength();
|
long total = snark.getTotalLength();
|
||||||
// Early typecast, avoid possibly overflowing a temp integer
|
long remaining = snark.getRemainingLength();
|
||||||
long remaining = (long) snark.getNeeded() * (long) snark.getPieceLength(0);
|
|
||||||
if (remaining > total)
|
if (remaining > total)
|
||||||
remaining = total;
|
remaining = total;
|
||||||
long downBps = snark.getDownloadRate();
|
long downBps = snark.getDownloadRate();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* Build Executor:
|
* Build Executor:
|
||||||
- Limit max parallel builds on really slow machines (ticket #519)
|
- Limit max parallel builds on really slow machines (ticket #519)
|
||||||
- Slow down build loop when network is apparently disconnected (ticket #519)
|
- Slow down build loop when network is apparently disconnected (ticket #519)
|
||||||
|
* i2psnark: Fix inaccuracy in the completed bytes display
|
||||||
* NetDB: Disable floodfill at shutdown time if enabled
|
* NetDB: Disable floodfill at shutdown time if enabled
|
||||||
|
|
||||||
2011-09-09 zzz
|
2011-09-09 zzz
|
||||||
|
Reference in New Issue
Block a user