From 9b98c0fc2e68bbfc6c779b8dbc29de34d524620a Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 14 Jul 2012 19:34:38 +0000 Subject: [PATCH] (trunk libT) #4969 "jsonrpc response to torrent-get emits malformed json" -- fixed. --- libtransmission/torrent.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 770347e90..378c357fe 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -1145,16 +1145,23 @@ tr_torrentIsStalled( const tr_torrent * tor ) static double getVerifyProgress( const tr_torrent * tor ) { - tr_piece_index_t i, n; - tr_piece_index_t checked = 0; + double d = 0; assert( tr_isTorrent( tor ) ); - for( i=0, n=tor->info.pieceCount; i!=n; ++i ) - if( tor->info.pieces[i].timeChecked ) - ++checked; + if( tr_torrentHasMetadata( tor ) ) + { + tr_piece_index_t i, n; + tr_piece_index_t checked = 0; - return checked / (double)tor->info.pieceCount; + for( i=0, n=tor->info.pieceCount; i!=n; ++i ) + if( tor->info.pieces[i].timeChecked ) + ++checked; + + d = checked / (double)tor->info.pieceCount; + } + + return d; } const tr_stat *