"pl", 1, "<files>" },
{ 'r', "remove", "Remove the current torrent(s)",
"r", 0, NULL },
+ { 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data",
+ NULL, 0, NULL },
{ 's', "start", "Start the current torrent(s)",
"s", 0, NULL },
{ 'S', "stop", "Stop the current torrent(s)",
addIdArg( args, id );
break;
+ case 'R':
+ tr_bencDictAddStr( &top, "method", "torrent-remove" );
+ addIdArg( args, id );
+ tr_bencDictAddInt( args, "delete-local-data", 1 );
+ break;
+
case 's':
tr_bencDictAddStr( &top, "method", "torrent-start" );
addIdArg( args, id );
.Op Fl pl Ar files
.Op Fl pn Ar files
.Op Fl r
+.Op Fl R
.Op Fl s | S
.Op Fl t Ar all | Ar id | Ar hash
.Op Fl u Ar number | Fl U
.It Fl r Fl -remove
Remove the current torrent(s). This does not delete the downloaded data.
+.It Fl -remove-and-delete
+Remove the current torrent(s) and delete their downloaded data.
+
.It Fl s Fl -start
Start the current torrent(s)
Method name | libtransmission function
--------------------+-------------------------------------------------
- "torrent-remove" | tr_torrentRemove
"torrent-start" | tr_torrentStart
"torrent-stop" | tr_torrentStop
"torrent-verify" | tr_torrentVerify
form of one of 3.3's tr_info objects with the
fields for id, name, and hashString.
+3.5. Removing a Torrent
+
+ Method name: "torrent-remove"
+
+ Request arguments:
+
+ string | value type & description
+ ---------------------------+-------------------------------------------------
+ "ids" | array torrent list, as described in 3.1
+ "delete-local-data" | 'boolean' delete local data. (default: false)
+
+ Response arguments: none
+
4. Session Requests
}
static const char*
-torrentRemove( tr_handle * h,
- tr_benc * args_in,
- tr_benc * args_out UNUSED )
+torrentRemove( tr_handle * h,
+ tr_benc * args_in,
+ tr_benc * args_out UNUSED )
{
- int i, torrentCount;
+ int i;
+ int torrentCount;
tr_torrent ** torrents = getTorrents( h, args_in, &torrentCount );
- for( i = 0; i < torrentCount; ++i )
+ for( i=0; i<torrentCount; ++i )
{
- tr_torrent * tor = torrents[i];
- const tr_rpc_callback_status status = notify(
- h, TR_RPC_TORRENT_REMOVING, tor );
+ tr_torrent * tor = torrents[i];
+ const tr_rpc_callback_status status = notify( h, TR_RPC_TORRENT_REMOVING, tor );
+ int64_t deleteFlag;
+ if( tr_bencDictFindInt( args_in, "delete-local-data", &deleteFlag ) && deleteFlag )
+ tr_torrentDeleteLocalData( tor );
if( !( status & TR_RPC_NOREMOVE ) )
tr_torrentRemove( tor );
}
}
}
+void
+tr_torrentDeleteLocalData( tr_torrent * tor )
+{
+ tr_file_index_t i;
+
+ for( i=0; i<tor->info.fileCount; ++i )
+ {
+ const tr_file * file = &tor->info.files[i];
+ char * path = tr_buildPath( tor->downloadDir, file->name, NULL );
+ tr_fdFileClose( path );
+ unlink( path );
+ tr_free( path );
+ }
+}
+
void
tr_torrentStop( tr_torrent * tor )
{
const char * shortName = opt->shortName ? opt->shortName : "";
const char * arg = getArgName( opt );
- printf( " -%-*s --%-*s %-*s %s\n", shortWidth, shortName,
- longWidth, longName,
+ printf( " %s%-*s %s%-*s %-*s %s\n",
+ (shortName && *shortName ? "-" : " "), shortWidth, shortName,
+ (longName && *longName ? "--" : " "), longWidth, longName,
argWidth, arg,
opt->description );
}
/** @brief Stop (pause) a torrent */
void tr_torrentStop( tr_torrent * torrent );
+/** @brief Deletes the torrent data stored on disk. */
+void tr_torrentDeleteLocalData( tr_torrent * torrent );
+
/**
* @brief Iterate through the torrents.
*