From: Charles Kerr <charles@transmissionbt.com> Date: Sun, 6 Apr 2008 14:42:47 +0000 (+0000) Subject: #843: download eta should consider availability X-Git-Tag: 1.20~245 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f3f0c03e675a451d773d09fdb5319d3fe92cedd;p=transmission #843: download eta should consider availability --- diff --git a/gtk/torrent-cell-renderer.c b/gtk/torrent-cell-renderer.c index d4b59da20..6d4940e17 100644 --- a/gtk/torrent-cell-renderer.c +++ b/gtk/torrent-cell-renderer.c @@ -83,7 +83,9 @@ getProgressString( const tr_info * info, const tr_stat * torStat ) const int eta = torStat->eta; GString * gstr = g_string_new( str ); g_string_append( gstr, " - " ); - if( eta < 0 ) + if( eta == TR_ETA_NOT_AVAIL ) + g_string_append( gstr, _( "Not available" ) ); + else if( eta == TR_ETA_UNKNOWN ) g_string_append( gstr, _( "Stalled" ) ); else { char timestr[128]; diff --git a/gtk/tr-torrent.c b/gtk/tr-torrent.c index d15b4afdd..7b035c36a 100644 --- a/gtk/tr-torrent.c +++ b/gtk/tr-torrent.c @@ -283,8 +283,11 @@ tr_torrent_status_str ( TrTorrent * gtor ) break; case TR_STATUS_DOWNLOAD: - if( eta < 0 ) - top = g_strdup_printf( _("Stalled (%.1f%%)"), prog ); + + if( eta == TR_ETA_NOT_AVAIL ) + top = g_strdup_printf( _("Not available (%.1f%%)" ), prog ); + else if( eta == TR_ETA_UNKNOWN ) + top = g_strdup_printf( _( "Stalled (%.1f%%)" ), prog ); else { char timestr[128]; tr_strltime( timestr, eta, sizeof( timestr ) ); diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 8c3256b4b..81cc292ba 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -626,10 +626,6 @@ tr_torrentStat( tr_torrent * tor ) s->startDate = tor->startDate; s->activityDate = tor->activityDate; - s->eta = s->rateDownload < 0.1 - ? -1.0f - : (s->leftUntilDone / s->rateDownload / 1024.0); - s->corruptEver = tor->corruptCur + tor->corruptPrev; s->downloadedEver = tor->downloadedCur + tor->downloadedPrev; s->uploadedEver = tor->uploadedCur + tor->uploadedPrev; @@ -660,6 +656,13 @@ tr_torrentStat( tr_torrent * tor ) tr_bitfieldFree( availablePieces ); } + if( s->desiredAvailable != s->leftUntilDone ) + s->eta = TR_ETA_NOT_AVAIL; + else if( s->rateDownload < 0.1 ) + s->eta = TR_ETA_UNKNOWN; + else + s->eta = s->leftUntilDone / (s->rateDownload / 1024.0); + s->ratio = tr_getRatio( s->uploadedEver, s->downloadedEver ? s->downloadedEver : s->haveValid ); diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 9c0dcd4c9..e3ba3123a 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -840,13 +840,26 @@ struct tr_stat tr_errno error; char errorString[128]; + /* [0..1] */ float recheckProgress; + + /* [0..1] */ float percentComplete; + + /* [0..1] */ float percentDone; + + /* KiB/s */ float rateDownload; + + /* KiB/s */ float rateUpload; - int eta; + #define TR_ETA_NOT_AVAIL -1 + #define TR_ETA_UNKNOWN -2 + /* seconds */ + int eta; + int peersKnown; int peersConnected; int peersFrom[TR_PEER_FROM__MAX];