Skip to content

Commit ee6f75e

Browse files
committed
Handle already completed and queued download
1 parent 1f9a114 commit ee6f75e

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

core/src/com/biglybt/pifimpl/local/utils/resourcedownloader/ResourceDownloaderTorrentImpl.java

+17-28
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
protected boolean completed;
7575

7676
protected ResourceDownloader current_downloader;
77-
protected Object result;
77+
protected volatile Object result;
7878
protected AESemaphore done_sem = new AESemaphore("RDTorrent");
7979

8080
public
@@ -549,42 +549,31 @@
549549
}
550550
});
551551

552-
Thread t =
553-
new AEThread( "RDTorrent percentage checker")
554-
{
555-
@Override
556-
public void
557-
runSupport()
558-
{
559-
int last_percentage = 0;
552+
AEThread2.createAndStartDaemon( "RDTorrent percentage checker",()->{
560553

561-
while( result == null ){
554+
int last_percentage = 0;
562555

563-
int this_percentage = download.getStats().getDownloadCompleted(false)/10;
556+
while( result == null ){
564557

565-
long total = torrent.getSize();
558+
int this_percentage = download.getStats().getDownloadCompleted(false)/10;
566559

567-
if ( this_percentage != last_percentage ){
560+
if ( this_percentage != last_percentage ){
568561

569-
reportPercentComplete( ResourceDownloaderTorrentImpl.this, this_percentage );
562+
reportPercentComplete( ResourceDownloaderTorrentImpl.this, this_percentage );
570563

571-
last_percentage = this_percentage;
572-
}
564+
last_percentage = this_percentage;
565+
}
573566

574-
try{
575-
Thread.sleep(1000);
567+
try{
568+
Thread.sleep(1000);
576569

577-
}catch( Throwable e ){
570+
}catch( Throwable e ){
578571

579-
Debug.printStackTrace( e );
580-
}
581-
}
572+
Debug.printStackTrace( e );
582573
}
583-
};
584-
585-
t.setDaemon( true );
586-
587-
t.start();
574+
}
575+
});
576+
588577

589578
int state = download.getState();
590579

@@ -594,7 +583,7 @@
594583

595584
download.start();
596585

597-
}else if ( state == Download.ST_SEEDING ){
586+
}else if ( state == Download.ST_SEEDING || download.isComplete()){
598587

599588
// its possible that the d/l has already occurred and it is seeding!
600589

0 commit comments

Comments
 (0)