]> granicus.if.org Git - transmission/commitdiff
(trunk) #3675 "Not all .part files are removed" -- handle trashing files via RPC.
authorJordan Lee <jordan@transmissionbt.com>
Sun, 6 Feb 2011 17:30:46 +0000 (17:30 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sun, 6 Feb 2011 17:30:46 +0000 (17:30 +0000)
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.

gtk/main.c
libtransmission/rpcimpl.c
libtransmission/transmission.h

index aeeb4a01fcbc2456d0fc2edbbaeed383f2ce6fac..859ab877bf2200af8b0bd5f4fcbf4e0cf368fd83 100644 (file)
@@ -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;
index c12035abb13ac6325fc7fd3eae0d39bcf8738b21..420ca1768f2ebb300c1d1257bef97396b05f0051 100644 (file)
@@ -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 );
index 6ff6fd76717c22366635f0626ecc7c929f855754..2aa9b96d866fc620e0de9d87c517b67d2fed344a 100644 (file)
@@ -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,