(trunk) #2960 "add torrent availability to web interface and remote" -- implemented via a patch from Longinus00

This commit is contained in:
Charles Kerr 2010-04-20 01:48:40 +00:00
parent 99a5412601
commit d3ac3b27e0
4 changed files with 27 additions and 6 deletions

View File

@ -324,6 +324,7 @@ static const char * details_keys[] = {
"corruptEver",
"creator",
"dateCreated",
"desiredAvailable",
"doneDate",
"downloadDir",
"downloadedEver",
@ -1275,12 +1276,22 @@ printDetails( tr_benc * top )
printf( " Have: %s (%s verified)\n", buf, buf2 );
}
if( tr_bencDictFindInt( t, "sizeWhenDone", &i )
&& tr_bencDictFindInt( t, "totalSize", &j ) )
if( tr_bencDictFindInt( t, "sizeWhenDone", &i ) )
{
strlsize( buf, j, sizeof( buf ) );
strlsize( buf2, i, sizeof( buf2 ) );
printf( " Total size: %s (%s wanted)\n", buf, buf2 );
if( i < 1 )
printf( " Availability: None\n" );
if( tr_bencDictFindInt( t, "desiredAvailable", &j)
&& tr_bencDictFindInt( t, "leftUntilDone", &k) )
{
j += i - k;
printf( " Availability: %.1f%%\n", ( 100 * j ) / (double) i );
}
if( tr_bencDictFindInt( t, "totalSize", &j ) )
{
strlsize( buf2, i, sizeof( buf2 ) );
strlsize( buf, j, sizeof( buf ) );
printf( " Total size: %s (%s wanted)\n", buf, buf2 );
}
}
if( tr_bencDictFindInt( t, "downloadedEver", &i )
&& tr_bencDictFindInt( t, "uploadedEver", &j ) )

View File

@ -135,6 +135,10 @@
<div class="inspector_label">Have:</div>
<div id="torrent_inspector_have">N/A</div>
</div>
<div class="inspector_row">
<div class="inspector_label">Availability:</div>
<div id="torrent_inspector_availability">N/A</div>
</div>
<div class="inspector_row">
<div class="inspector_label">Downloaded:</div>
<div id="torrent_inspector_downloaded">N/A</div>

View File

@ -41,7 +41,7 @@ Torrent._MetaDataFields = [ 'addedDate', 'comment', 'creator', 'dateCreated',
Torrent._DynamicFields = [ 'downloadedEver', 'error', 'errorString', 'eta',
'haveUnchecked', 'haveValid', 'leftUntilDone', 'metadataPercentComplete', 'peersConnected',
'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload',
'recheckProgress', 'sizeWhenDone', 'status', 'trackerStats',
'recheckProgress', 'sizeWhenDone', 'status', 'trackerStats', 'desiredAvailable',
'uploadedEver', 'uploadRatio', 'seedRatioLimit', 'seedRatioMode', 'downloadDir', 'isFinished' ]
Torrent.prototype =
@ -393,6 +393,7 @@ Torrent.prototype =
this._download_dir = data.downloadDir;
this._metadataPercentComplete = data.metadataPercentComplete;
this._isFinishedSeeding = data.isFinished;
this._desiredAvailable = data.desiredAvailable;
if (data.fileStats)
this.refreshFileModel( data );

View File

@ -90,6 +90,7 @@ Transmission.prototype =
var ti = '#torrent_inspector_';
this._inspector = { };
this._inspector._info_tab = { };
this._inspector._info_tab.availability = $(ti+'availability')[0];
this._inspector._info_tab.comment = $(ti+'comment')[0];
this._inspector._info_tab.creator_date = $(ti+'creator_date')[0];
this._inspector._info_tab.creator = $(ti+'creator')[0];
@ -1147,6 +1148,7 @@ Transmission.prototype =
var total_download = 0;
var total_download_peers = 0;
var total_download_speed = 0;
var total_availability = 0;
var total_have = 0;
var total_size = 0;
var total_state = null;
@ -1171,6 +1173,7 @@ Transmission.prototype =
setInnerHTML( tab.upload_speed, na );
setInnerHTML( tab.uploaded, na );
setInnerHTML( tab.downloaded, na );
setInnerHTML( tab.availability, na );
setInnerHTML( tab.ratio, na );
setInnerHTML( tab.have, na );
setInnerHTML( tab.upload_to, na );
@ -1222,6 +1225,7 @@ Transmission.prototype =
total_download_speed += t.downloadSpeed();
total_upload_peers += t.peersGettingFromUs();
total_download_peers += t.peersSendingToUs();
total_availability += t._sizeWhenDone - t._leftUntilDone + t._desiredAvailable;
if( total_state == null )
total_state = t.stateStr();
else if ( total_state.search ( t.stateStr() ) == -1 )
@ -1246,6 +1250,7 @@ Transmission.prototype =
setInnerHTML( tab.upload_speed, torrents.length ? Math.formatBytes( total_upload_speed ) + '/s' : na );
setInnerHTML( tab.uploaded, torrents.length ? Math.formatBytes( total_upload ) : na );
setInnerHTML( tab.downloaded, torrents.length ? Math.formatBytes( total_download ) : na );
setInnerHTML( tab.availability, torrents.length ? Math.ratio( total_availability*100, sizeWhenDone ) + '%' : na );
setInnerHTML( tab.ratio, torrents.length ? Math.ratio( total_upload, total_download ) : na );
setInnerHTML( tab.have, torrents.length ? Math.formatBytes(total_completed) + ' (' + Math.formatBytes(total_verified) + ' verified)' : na );
setInnerHTML( tab.upload_to, torrents.length ? total_upload_peers : na );