Changeset 09e867b1


Ignore:
Timestamp:
Jun 2, 2015 8:14:33 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
39dc60c
Parents:
dc9256f
Message:

i2psnark: Don't say 'download finished' unless we downloaded something
atomics

Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
2 edited

Legend:

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

    rdc9256f r09e867b1  
    3434import java.util.Set;
    3535import java.util.concurrent.LinkedBlockingDeque;
     36import java.util.concurrent.atomic.AtomicLong;
    3637
    3738import net.i2p.I2PAppContext;
     
    8889  // int downloaders = 0;
    8990
    90   private long uploaded;
    91   private long downloaded;
     91  private final AtomicLong uploaded = new AtomicLong();
     92  private final AtomicLong downloaded = new AtomicLong();
    9293  final static int RATE_DEPTH = 3; // make following arrays RATE_DEPTH long
    9394  private final long uploaded_old[] = {-1,-1,-1};
     
    280281  public long getUploaded()
    281282  {
    282     return uploaded;
     283    return uploaded.get();
    283284  }
    284285
     
    288289   */
    289290  public void setUploaded(long up) {
    290       uploaded = up;
     291      uploaded.set(up);
    291292  }
    292293
     
    296297  public long getDownloaded()
    297298  {
    298     return downloaded;
     299    return downloaded.get();
    299300  }
    300301
     
    945946  public void uploaded(Peer peer, int size)
    946947  {
    947     uploaded += size;
     948    uploaded.addAndGet(size);
    948949
    949950    //if (listener != null)
     
    956957  public void downloaded(Peer peer, int size)
    957958  {
    958     downloaded += size;
     959    downloaded.addAndGet(size);
    959960
    960961    //if (listener != null)
     
    10051006              {
    10061007                // Oops. We didn't actually download this then... :(
    1007                 downloaded -= metainfo.getPieceLength(piece);
     1008                downloaded.addAndGet(0 - metainfo.getPieceLength(piece));
    10081009                _log.warn("Got BAD piece " + piece + "/" + metainfo.getPieces() + " from " + peer + " for " + metainfo.getName());
    10091010                return false; // No need to announce BAD piece to peers.
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    rdc9256f r09e867b1  
    19771977            buf.append('/');
    19781978        buf.append("\">").append(base).append("</a>");
    1979         addMessageNoEscape(_("Download finished: {0}", buf.toString())); //  + " (" + _("size: {0}B", DataHelper.formatSize2(len)) + ')');
     1979        if (snark.getDownloaded() > 0)
     1980            addMessageNoEscape(_("Download finished: {0}", buf.toString())); //  + " (" + _("size: {0}B", DataHelper.formatSize2(len)) + ')');
    19801981        updateStatus(snark);
    19811982    }
Note: See TracChangeset for help on using the changeset viewer.