mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
(daemon) #1510: kysucix's patch to give an option to delete local data via RPC when removing a torrent.
This commit is contained in:
@@ -99,6 +99,8 @@ static tr_option opts[] =
|
|||||||
"pl", 1, "<files>" },
|
"pl", 1, "<files>" },
|
||||||
{ 'r', "remove", "Remove the current torrent(s)",
|
{ 'r', "remove", "Remove the current torrent(s)",
|
||||||
"r", 0, NULL },
|
"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', "start", "Start the current torrent(s)",
|
||||||
"s", 0, NULL },
|
"s", 0, NULL },
|
||||||
{ 'S', "stop", "Stop the current torrent(s)",
|
{ 'S', "stop", "Stop the current torrent(s)",
|
||||||
@@ -414,6 +416,12 @@ readargs( int argc,
|
|||||||
addIdArg( args, id );
|
addIdArg( args, id );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'R':
|
||||||
|
tr_bencDictAddStr( &top, "method", "torrent-remove" );
|
||||||
|
addIdArg( args, id );
|
||||||
|
tr_bencDictAddInt( args, "delete-local-data", 1 );
|
||||||
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
tr_bencDictAddStr( &top, "method", "torrent-start" );
|
tr_bencDictAddStr( &top, "method", "torrent-start" );
|
||||||
addIdArg( args, id );
|
addIdArg( args, id );
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ and
|
|||||||
.Op Fl pl Ar files
|
.Op Fl pl Ar files
|
||||||
.Op Fl pn Ar files
|
.Op Fl pn Ar files
|
||||||
.Op Fl r
|
.Op Fl r
|
||||||
|
.Op Fl R
|
||||||
.Op Fl s | S
|
.Op Fl s | S
|
||||||
.Op Fl t Ar all | Ar id | Ar hash
|
.Op Fl t Ar all | Ar id | Ar hash
|
||||||
.Op Fl u Ar number | Fl U
|
.Op Fl u Ar number | Fl U
|
||||||
@@ -134,6 +135,9 @@ Mark file(s) as low priority.
|
|||||||
.It Fl r Fl -remove
|
.It Fl r Fl -remove
|
||||||
Remove the current torrent(s). This does not delete the downloaded data.
|
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
|
.It Fl s Fl -start
|
||||||
Start the current torrent(s)
|
Start the current torrent(s)
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
|
|
||||||
Method name | libtransmission function
|
Method name | libtransmission function
|
||||||
--------------------+-------------------------------------------------
|
--------------------+-------------------------------------------------
|
||||||
"torrent-remove" | tr_torrentRemove
|
|
||||||
"torrent-start" | tr_torrentStart
|
"torrent-start" | tr_torrentStart
|
||||||
"torrent-stop" | tr_torrentStop
|
"torrent-stop" | tr_torrentStop
|
||||||
"torrent-verify" | tr_torrentVerify
|
"torrent-verify" | tr_torrentVerify
|
||||||
@@ -293,6 +292,19 @@
|
|||||||
form of one of 3.3's tr_info objects with the
|
form of one of 3.3's tr_info objects with the
|
||||||
fields for id, name, and hashString.
|
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
|
4. Session Requests
|
||||||
|
|
||||||
|
|||||||
@@ -136,18 +136,21 @@ torrentStop( tr_handle * h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
torrentRemove( tr_handle * h,
|
torrentRemove( tr_handle * h,
|
||||||
tr_benc * args_in,
|
tr_benc * args_in,
|
||||||
tr_benc * args_out UNUSED )
|
tr_benc * args_out UNUSED )
|
||||||
{
|
{
|
||||||
int i, torrentCount;
|
int i;
|
||||||
|
int torrentCount;
|
||||||
tr_torrent ** torrents = getTorrents( h, args_in, &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];
|
tr_torrent * tor = torrents[i];
|
||||||
const tr_rpc_callback_status status = notify(
|
const tr_rpc_callback_status status = notify( h, TR_RPC_TORRENT_REMOVING, tor );
|
||||||
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 ) )
|
if( !( status & TR_RPC_NOREMOVE ) )
|
||||||
tr_torrentRemove( tor );
|
tr_torrentRemove( tor );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1197,6 +1197,21 @@ stopTorrent( void * vtor )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
tr_torrentStop( tr_torrent * tor )
|
tr_torrentStop( tr_torrent * tor )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,8 +47,9 @@ getopts_usage_line( const tr_option * opt,
|
|||||||
const char * shortName = opt->shortName ? opt->shortName : "";
|
const char * shortName = opt->shortName ? opt->shortName : "";
|
||||||
const char * arg = getArgName( opt );
|
const char * arg = getArgName( opt );
|
||||||
|
|
||||||
printf( " -%-*s --%-*s %-*s %s\n", shortWidth, shortName,
|
printf( " %s%-*s %s%-*s %-*s %s\n",
|
||||||
longWidth, longName,
|
(shortName && *shortName ? "-" : " "), shortWidth, shortName,
|
||||||
|
(longName && *longName ? "--" : " "), longWidth, longName,
|
||||||
argWidth, arg,
|
argWidth, arg,
|
||||||
opt->description );
|
opt->description );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -840,6 +840,9 @@ void tr_torrentStart( tr_torrent * torrent );
|
|||||||
/** @brief Stop (pause) a torrent */
|
/** @brief Stop (pause) a torrent */
|
||||||
void tr_torrentStop( tr_torrent * 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.
|
* @brief Iterate through the torrents.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user