Changeset 61831b1


Ignore:
Timestamp:
Sep 12, 2011 2:03:51 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
0018ac0
Parents:
5401721
Message:
  • i2psnark: Fix inaccuracy in the completed bytes display
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/Snark.java

    r5401721 r61831b1  
    781781
    782782    /**
     783     *  @return exact value. or -1 if no storage yet.
     784     *          getNeeded() * pieceLength(0) isn't accurate if last piece
     785     *          is still needed.
     786     *  @since 0.8.9
     787     */
     788    public long getRemainingLength() {
     789        if (meta != null && storage != null) {
     790            long needed = storage.needed();
     791            long length0 = meta.getPieceLength(0);
     792            long remaining = needed * length0;
     793            // fixup if last piece is needed
     794            int last = meta.getPieces() - 1;
     795            if (last != 0 && !storage.getBitField().get(last))
     796                remaining -= length0 - meta.getPieceLength(last);
     797            return remaining;
     798        }
     799        return -1;
     800    }
     801
     802    /**
    783803     *  @return number of pieces still needed (magnet mode or not), or -1 if unknown
    784804     *  @since 0.8.4
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r5401721 r61831b1  
    766766        }
    767767        long total = snark.getTotalLength();
    768         // Early typecast, avoid possibly overflowing a temp integer
    769         long remaining = (long) snark.getNeeded() * (long) snark.getPieceLength(0);
     768        long remaining = snark.getRemainingLength();
    770769        if (remaining > total)
    771770            remaining = total;
  • history.txt

    r5401721 r61831b1  
    33    - Limit max parallel builds on really slow machines (ticket #519)
    44    - Slow down build loop when network is apparently disconnected (ticket #519)
     5  * i2psnark: Fix inaccuracy in the completed bytes display
    56  * NetDB: Disable floodfill at shutdown time if enabled
    67
Note: See TracChangeset for help on using the changeset viewer.