mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk) more magnet fixes
This commit is contained in:
parent
bda3103740
commit
3610c5ea62
6 changed files with 40 additions and 10 deletions
|
@ -518,7 +518,7 @@ addURLDialog( GtkWindow * parent, TrCore * core )
|
|||
GtkWidget * t;
|
||||
GtkWidget * w;
|
||||
|
||||
w = gtk_dialog_new_with_buttons( _( "Add a URL" ), parent,
|
||||
w = gtk_dialog_new_with_buttons( _( "Add URL" ), parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
|
||||
|
|
|
@ -260,11 +260,11 @@ getStatusString( const tr_torrent * tor,
|
|||
else
|
||||
{
|
||||
g_string_append_printf( gstr,
|
||||
ngettext( "Downloading .torrent data from %1$'d peer",
|
||||
"Downloading .torrent data from %1$'d peers",
|
||||
ngettext( "Downloading .torrent data from %1$'d peer (%2$d%% done)",
|
||||
"Downloading .torrent data from %1$'d peers (%2$d%% done)",
|
||||
torStat->peersConnected ),
|
||||
torStat->peersConnected +
|
||||
torStat->webseedsSendingToUs );
|
||||
torStat->peersConnected + torStat->webseedsSendingToUs,
|
||||
(int)(100.0*torStat->metadataPercentComplete) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
enum
|
||||
{
|
||||
/* don't ask for the same metadata piece more than this often */
|
||||
MIN_REPEAT_INTERVAL_SECS = 5
|
||||
MIN_REPEAT_INTERVAL_SECS = 3
|
||||
};
|
||||
|
||||
struct metadata_node
|
||||
|
@ -220,6 +220,7 @@ tr_torrentSetMetadataPiece( tr_torrent * tor,
|
|||
tr_bencToFile( &dict, TR_FMT_BENC, path );
|
||||
tr_sessionSetTorrentFile( tor->session,
|
||||
tor->info.hashString, path );
|
||||
tr_torrentSetDirty( tor );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ tr_torrentGetNextMetadataRequest( tr_torrent * tor, time_t now, int * setme_piec
|
|||
|
||||
if( ( m != NULL )
|
||||
&& ( m->piecesNeededCount > 0 )
|
||||
&& ( m->piecesNeeded[0].requestedAt + MIN_REPEAT_INTERVAL_SECS <= now ) )
|
||||
&& ( m->piecesNeeded[0].requestedAt + MIN_REPEAT_INTERVAL_SECS < now ) )
|
||||
{
|
||||
int i;
|
||||
const int piece = m->piecesNeeded[0].piece;
|
||||
|
@ -266,8 +267,8 @@ tr_torrentGetNextMetadataRequest( tr_torrent * tor, time_t now, int * setme_piec
|
|||
m->piecesNeededCount-- );
|
||||
|
||||
i = m->piecesNeededCount++;
|
||||
m->piecesNeeded[0].piece = piece;
|
||||
m->piecesNeeded[0].requestedAt = now;
|
||||
m->piecesNeeded[i].piece = piece;
|
||||
m->piecesNeeded[i].requestedAt = now;
|
||||
|
||||
dbgmsg( tor, "next piece to request: %d", piece );
|
||||
*setme_piece = piece;
|
||||
|
@ -276,3 +277,21 @@ tr_torrentGetNextMetadataRequest( tr_torrent * tor, time_t now, int * setme_piec
|
|||
|
||||
return have_request;
|
||||
}
|
||||
|
||||
float
|
||||
tr_torrentGetMetadataPercent( const tr_torrent * tor )
|
||||
{
|
||||
float ret;
|
||||
|
||||
if( tr_torrentHasMetadata( tor ) )
|
||||
ret = 1.0;
|
||||
else {
|
||||
const struct tr_incomplete_metadata * m = tor->incompleteMetadata;
|
||||
if( m == NULL )
|
||||
ret = 0.0;
|
||||
else
|
||||
ret = (m->pieceCount - m->piecesNeededCount) / (float)m->pieceCount;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -33,4 +33,6 @@ tr_bool tr_torrentGetNextMetadataRequest( tr_torrent * tor, time_t now, int * se
|
|||
|
||||
void tr_torrentSetMetadataSizeHint( tr_torrent * tor, int metadata_size );
|
||||
|
||||
float tr_torrentGetMetadataPercent( const tr_torrent * tor );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "ratecontrol.h"
|
||||
#include "session.h"
|
||||
#include "torrent.h"
|
||||
#include "torrent-magnet.h"
|
||||
#include "trevent.h"
|
||||
#include "utils.h"
|
||||
#include "verify.h"
|
||||
|
@ -959,6 +960,7 @@ tr_torrentStat( tr_torrent * tor )
|
|||
usableSeeds += tor->info.webseedCount;
|
||||
|
||||
s->percentComplete = tr_cpPercentComplete ( &tor->completion );
|
||||
s->metadataPercentComplete = tr_torrentGetMetadataPercent( tor );
|
||||
|
||||
s->percentDone = tr_cpPercentDone ( &tor->completion );
|
||||
s->leftUntilDone = tr_cpLeftUntilDone( &tor->completion );
|
||||
|
@ -1468,7 +1470,8 @@ tr_torrentSave( tr_torrent * tor )
|
|||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
if( tor->isDirty ) {
|
||||
if( tor->isDirty && tr_torrentHasMetadata( tor ) )
|
||||
{
|
||||
tor->isDirty = FALSE;
|
||||
tr_torrentSaveResume( tor );
|
||||
}
|
||||
|
|
|
@ -1634,6 +1634,12 @@ typedef struct tr_stat
|
|||
Range is [0..1] */
|
||||
float percentComplete;
|
||||
|
||||
/** How much of the metadata the torrent has.
|
||||
For torrents added from a .torrent this will always be 1.
|
||||
For magnet links, this number will from from 0 to 1 as the metadata is downloaded.
|
||||
Range is [0..1] */
|
||||
float metadataPercentComplete;
|
||||
|
||||
/** How much has been downloaded of the files the user wants. This differs
|
||||
from percentComplete if the user wants only some of the torrent's files.
|
||||
Range is [0..1]
|
||||
|
|
Loading…
Reference in a new issue