mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
#1101 (rpc): add individual file progress to torrent-get's "files" message
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
.Op Fl g Ar directory
|
||||
.Op Fl h
|
||||
.Op Fl m | M
|
||||
.Op Fl p
|
||||
.Op Fl p Ar port
|
||||
.Op Fl t
|
||||
.Op Fl u Ar number | Fl U
|
||||
.Op Fl v
|
||||
|
||||
+5
-2
@@ -615,9 +615,10 @@ printFileList( tr_benc * top )
|
||||
{
|
||||
int j=0, jn=tr_bencListSize(files);
|
||||
printf( "%s (%d files):\n", name, jn );
|
||||
printf("%3s %8s %3s %9s %s\n", "#", "Priority", "Get", "Size", "Name" );
|
||||
printf("%3s %4s %8s %3s %9s %s\n", "#", "Done", "Priority", "Get", "Size", "Name" );
|
||||
for( j=0, jn=tr_bencListSize( files ); j<jn; ++j )
|
||||
{
|
||||
int64_t have;
|
||||
int64_t length;
|
||||
int64_t priority;
|
||||
int64_t wanted;
|
||||
@@ -625,10 +626,12 @@ printFileList( tr_benc * top )
|
||||
tr_benc * file = tr_bencListChild( files, j );
|
||||
if( tr_bencDictFindInt( file, "length", &length ) &&
|
||||
tr_bencDictFindStr( file, "name", &filename ) &&
|
||||
tr_bencDictFindInt( file, "bytesCompleted", &have ) &&
|
||||
tr_bencGetInt( tr_bencListChild( priorities, j ), &priority ) &&
|
||||
tr_bencGetInt( tr_bencListChild( wanteds, j ), &wanted ) )
|
||||
{
|
||||
char sizestr[64];
|
||||
double percent = (double)have / length;
|
||||
strlsize( sizestr, length, sizeof( sizestr ) );
|
||||
const char * pristr;
|
||||
switch( priority ) {
|
||||
@@ -636,7 +639,7 @@ printFileList( tr_benc * top )
|
||||
case TR_PRI_HIGH: pristr = "High"; break;
|
||||
default: pristr = "Normal"; break;
|
||||
}
|
||||
printf( "%3d: %-8s %-3s %9s %s\n", (j+1), pristr, (wanted?"Yes":"No"), sizestr, filename );
|
||||
printf( "%3d: %3.0f%% %-8s %-3s %9s %s\n", (j+1), percent, pristr, (wanted?"Yes":"No"), sizestr, filename );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
+----------+--------------------------------------
|
||||
| files is an array of objects that contain:
|
||||
+----------+------------------------+-------------
|
||||
| number | bytesCompleted | tr_torrent
|
||||
| number | length | tr_info
|
||||
| string | name | tr_info
|
||||
-------------------+----------+------------------------+-------------
|
||||
|
||||
+10
-3
@@ -156,16 +156,23 @@ torrentVerify( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
|
||||
***/
|
||||
|
||||
static void
|
||||
addFiles( const tr_info * info, tr_benc * files )
|
||||
addFiles( const tr_torrent * tor, tr_benc * list )
|
||||
{
|
||||
tr_file_index_t i;
|
||||
tr_file_index_t n;
|
||||
const tr_info * info = tr_torrentInfo( tor );
|
||||
tr_file_stat * files = tr_torrentFiles( tor, &n );
|
||||
|
||||
for( i=0; i<info->fileCount; ++i )
|
||||
{
|
||||
const tr_file * file = &info->files[i];
|
||||
tr_benc * d = tr_bencListAddDict( files, 2 );
|
||||
tr_benc * d = tr_bencListAddDict( list, 3 );
|
||||
tr_bencDictAddInt( d, "bytesCompleted", files[i].bytesCompleted );
|
||||
tr_bencDictAddInt( d, "length", file->length );
|
||||
tr_bencDictAddStr( d, "name", file->name );
|
||||
}
|
||||
|
||||
tr_torrentFilesFree( files, n );
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -227,7 +234,7 @@ addInfo( const tr_torrent * tor, tr_benc * d, uint64_t fields )
|
||||
}
|
||||
|
||||
if( fields & TR_RPC_TORRENT_FILES )
|
||||
addFiles( inf, tr_bencDictAddList( d, "files", inf->fileCount ) );
|
||||
addFiles( tor, tr_bencDictAddList( d, "files", inf->fileCount ) );
|
||||
|
||||
if( fields & TR_RPC_TORRENT_HISTORY ) {
|
||||
tr_bencDictAddInt( d, "activityDate", st->activityDate );
|
||||
|
||||
Reference in New Issue
Block a user