]> granicus.if.org Git - transmission/commitdiff
#843: download eta should consider availability
authorCharles Kerr <charles@transmissionbt.com>
Sun, 6 Apr 2008 14:42:47 +0000 (14:42 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 6 Apr 2008 14:42:47 +0000 (14:42 +0000)
gtk/torrent-cell-renderer.c
gtk/tr-torrent.c
libtransmission/torrent.c
libtransmission/transmission.h

index d4b59da200f253a358cceec235a3d9965a6a7d76..6d4940e17fa5b30b9f88d649a3677bc17f45f394 100644 (file)
@@ -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];
index d15b4afdd32d6dde01e9383d5b1e5f5513767965..7b035c36ad1f246d60e61b5545cb82bf519e6b94 100644 (file)
@@ -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 ) );
index 8c3256b4b69a8181695d294d5aaaa4d9b65cfa34..81cc292ba406139a7973e08a231466d06f71c7ff 100644 (file)
@@ -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 );
     
index 9c0dcd4c95f8ca8736ac88db1dee9f7984c063ac..e3ba3123a8429b0831caf44d00eba9b0ef9da42d 100644 (file)
@@ -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];