mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
(trunk) #3675 "Not all .part files are removed" -- handle trashing files via RPC.
When libtransmission gets a "remove torrent" request from RPC, it tries to delegate the work. This is because the GTK+ and Mac clients don't want torrents disappearing in a different thread and causing possible thread issues. So the GTK+ and Mac clients get notification about this via libtransmission's RPC callback and remove the torrents themselves. Unfortunately, that notification doesn't include information about whether or not to delete local data. This commit adds that information to the RPC callback so that the Mac and GTK+ clients will know whether or not to trash the local files when a third-party RPC client requests that at torrent and its files be deleted.
This commit is contained in:
parent
11c0517cc8
commit
1fabb9b9ea
3 changed files with 13 additions and 7 deletions
|
@ -453,6 +453,7 @@ struct torrent_idle_data
|
|||
{
|
||||
TrCore * core;
|
||||
int id;
|
||||
gboolean delete_files;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
|
@ -460,7 +461,7 @@ rpc_torrent_remove_idle( gpointer gdata )
|
|||
{
|
||||
struct torrent_idle_data * data = gdata;
|
||||
|
||||
tr_core_remove_torrent_from_id( data->core, data->id, FALSE );
|
||||
tr_core_remove_torrent_from_id( data->core, data->id, data->delete_files );
|
||||
|
||||
g_free( data );
|
||||
return FALSE; /* tell g_idle not to call this func twice */
|
||||
|
@ -511,10 +512,12 @@ onRPCChanged( tr_session * session,
|
|||
break;
|
||||
}
|
||||
|
||||
case TR_RPC_TORRENT_REMOVING: {
|
||||
case TR_RPC_TORRENT_REMOVING:
|
||||
case TR_RPC_TORRENT_TRASHING: {
|
||||
struct torrent_idle_data * data = g_new0( struct torrent_idle_data, 1 );
|
||||
data->id = tr_torrentId( tor );
|
||||
data->core = cbdata->core;
|
||||
data->delete_files = type == TR_RPC_TORRENT_TRASHING;
|
||||
gtr_idle_add( rpc_torrent_remove_idle, data );
|
||||
status = TR_RPC_NOREMOVE;
|
||||
break;
|
||||
|
|
|
@ -244,20 +244,22 @@ torrentRemove( tr_session * session,
|
|||
{
|
||||
int i;
|
||||
int torrentCount;
|
||||
tr_rpc_callback_type type;
|
||||
tr_bool deleteFlag = FALSE;
|
||||
tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
|
||||
|
||||
assert( idle_data == NULL );
|
||||
|
||||
tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
|
||||
type = deleteFlag ? TR_RPC_TORRENT_TRASHING
|
||||
: TR_RPC_TORRENT_REMOVING;
|
||||
|
||||
for( i=0; i<torrentCount; ++i )
|
||||
{
|
||||
tr_torrent * tor = torrents[i];
|
||||
const tr_rpc_callback_status status = notify( session, TR_RPC_TORRENT_REMOVING, tor );
|
||||
const tr_rpc_callback_status status = notify( session, type, tor );
|
||||
if( !( status & TR_RPC_NOREMOVE ) )
|
||||
{
|
||||
tr_bool deleteFlag = FALSE;
|
||||
tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
|
||||
tr_torrentRemove( tor, deleteFlag, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
tr_free( torrents );
|
||||
|
|
|
@ -497,6 +497,7 @@ typedef enum
|
|||
TR_RPC_TORRENT_STARTED,
|
||||
TR_RPC_TORRENT_STOPPED,
|
||||
TR_RPC_TORRENT_REMOVING,
|
||||
TR_RPC_TORRENT_TRASHING, /* _REMOVING + delete local data */
|
||||
TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
|
||||
TR_RPC_TORRENT_MOVED,
|
||||
TR_RPC_SESSION_CHANGED,
|
||||
|
|
Loading…
Reference in a new issue