Changeset 11834


Ignore:
Timestamp:
Feb 6, 2011, 5:30:46 PM (11 years ago)
Author:
jordan
Message:

(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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r11831 r11834  
    454454    TrCore * core;
    455455    int id;
     456    gboolean delete_files;
    456457};
    457458
     
    461462    struct torrent_idle_data * data = gdata;
    462463
    463     tr_core_remove_torrent_from_id( data->core, data->id, FALSE );
     464    tr_core_remove_torrent_from_id( data->core, data->id, data->delete_files );
    464465
    465466    g_free( data );
     
    512513        }
    513514
    514         case TR_RPC_TORRENT_REMOVING: {
     515        case TR_RPC_TORRENT_REMOVING:
     516        case TR_RPC_TORRENT_TRASHING: {
    515517            struct torrent_idle_data * data = g_new0( struct torrent_idle_data, 1 );
    516518            data->id = tr_torrentId( tor );
    517519            data->core = cbdata->core;
     520            data->delete_files = type == TR_RPC_TORRENT_TRASHING;
    518521            gtr_idle_add( rpc_torrent_remove_idle, data );
    519522            status = TR_RPC_NOREMOVE;
  • trunk/libtransmission/rpcimpl.c

    r11709 r11834  
    245245    int i;
    246246    int torrentCount;
     247    tr_rpc_callback_type type;
     248    tr_bool deleteFlag = FALSE;
    247249    tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
    248250
    249251    assert( idle_data == NULL );
    250252
     253    tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
     254    type = deleteFlag ? TR_RPC_TORRENT_TRASHING
     255                      : TR_RPC_TORRENT_REMOVING;
     256
    251257    for( i=0; i<torrentCount; ++i )
    252258    {
    253259        tr_torrent * tor = torrents[i];
    254         const tr_rpc_callback_status status = notify( session, TR_RPC_TORRENT_REMOVING, tor );
     260        const tr_rpc_callback_status status = notify( session, type, tor );
    255261        if( !( status & TR_RPC_NOREMOVE ) )
    256         {
    257             tr_bool deleteFlag = FALSE;
    258             tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag );
    259262            tr_torrentRemove( tor, deleteFlag, NULL );
    260         }
    261263    }
    262264
  • trunk/libtransmission/transmission.h

    r11812 r11834  
    498498    TR_RPC_TORRENT_STOPPED,
    499499    TR_RPC_TORRENT_REMOVING,
     500    TR_RPC_TORRENT_TRASHING, /* _REMOVING + delete local data */
    500501    TR_RPC_TORRENT_CHANGED, /* catch-all for the "torrent-set" rpc method */
    501502    TR_RPC_TORRENT_MOVED,
Note: See TracChangeset for help on using the changeset viewer.