Changeset 7331


Ignore:
Timestamp:
Dec 9, 2008, 5:01:49 PM (12 years ago)
Author:
charles
Message:

(daemon) #1510: kysucix's patch to give an option to delete local data via RPC when removing a torrent.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r7202 r7331  
    100100    { 'r', "remove",               "Remove the current torrent(s)",
    101101      "r",  0, NULL                  },
     102    { 'R', "remove-and-delete",    "Remove the current torrent(s) and delete local data",
     103      NULL, 0, NULL                  },
    102104    { 's', "start",                "Start the current torrent(s)",
    103105      "s",  0, NULL                  },
     
    413415                tr_bencDictAddStr( &top, "method", "torrent-remove" );
    414416                addIdArg( args, id );
     417                break;
     418
     419            case 'R':
     420                tr_bencDictAddStr( &top, "method", "torrent-remove" );
     421                addIdArg( args, id );
     422                tr_bencDictAddInt( args, "delete-local-data", 1 );
    415423                break;
    416424
  • trunk/daemon/transmission-remote.1

    r7108 r7331  
    2929.Op Fl pn Ar files
    3030.Op Fl r
     31.Op Fl R
    3132.Op Fl s | S
    3233.Op Fl t Ar all | Ar id | Ar hash
     
    134135.It Fl r Fl -remove
    135136Remove the current torrent(s).  This does not delete the downloaded data.
     137
     138.It Fl -remove-and-delete
     139Remove the current torrent(s) and delete their downloaded data.
    136140
    137141.It Fl s Fl -start
  • trunk/doc/rpc-spec.txt

    r7264 r7331  
    6969   Method name         | libtransmission function
    7070   --------------------+-------------------------------------------------
    71    "torrent-remove"    | tr_torrentRemove
    7271   "torrent-start"     | tr_torrentStart
    7372   "torrent-stop"      | tr_torrentStop
     
    294293                       fields for id, name, and hashString.
    295294
     2953.5.  Removing a Torrent
     296
     297   Method name: "torrent-remove"
     298
     299   Request arguments:
     300
     301   string                     | value type & description
     302   ---------------------------+-------------------------------------------------
     303   "ids"                      | array      torrent list, as described in 3.1
     304   "delete-local-data"        | 'boolean'  delete local data. (default: false)
     305
     306   Response arguments: none
     307
    296308
    2973094.   Session Requests
  • trunk/libtransmission/rpcimpl.c

    r7238 r7331  
    137137
    138138static const char*
    139 torrentRemove( tr_handle *        h,
    140                tr_benc *          args_in,
    141                tr_benc * args_out UNUSED )
    142 {
    143     int           i, torrentCount;
     139torrentRemove( tr_handle   * h,
     140               tr_benc     * args_in,
     141               tr_benc     * args_out UNUSED )
     142{
     143    int i;
     144    int torrentCount;
    144145    tr_torrent ** torrents = getTorrents( h, args_in, &torrentCount );
    145146
    146     for( i = 0; i < torrentCount; ++i )
    147     {
    148         tr_torrent *                 tor = torrents[i];
    149         const tr_rpc_callback_status status = notify(
    150             h, TR_RPC_TORRENT_REMOVING, tor );
     147    for( i=0; i<torrentCount; ++i )
     148    {
     149        tr_torrent * tor = torrents[i];
     150        const tr_rpc_callback_status status = notify( h, TR_RPC_TORRENT_REMOVING, tor );
     151        int64_t deleteFlag;
     152        if( tr_bencDictFindInt( args_in, "delete-local-data", &deleteFlag ) && deleteFlag )
     153            tr_torrentDeleteLocalData( tor );
    151154        if( !( status & TR_RPC_NOREMOVE ) )
    152155            tr_torrentRemove( tor );
  • trunk/libtransmission/torrent.c

    r7329 r7331  
    11991199
    12001200void
     1201tr_torrentDeleteLocalData( tr_torrent * tor )
     1202{
     1203    tr_file_index_t i;
     1204
     1205    for( i=0; i<tor->info.fileCount; ++i )
     1206    {
     1207        const tr_file * file = &tor->info.files[i];
     1208        char * path = tr_buildPath( tor->downloadDir, file->name, NULL );
     1209        tr_fdFileClose( path );
     1210        unlink( path );
     1211        tr_free( path );
     1212    }
     1213}
     1214
     1215void
    12011216tr_torrentStop( tr_torrent * tor )
    12021217{
  • trunk/libtransmission/tr-getopt.c

    r7200 r7331  
    4848    const char * arg        = getArgName( opt );
    4949
    50     printf( "  -%-*s --%-*s %-*s  %s\n", shortWidth, shortName,
    51             longWidth, longName,
     50    printf( "  %s%-*s %s%-*s %-*s  %s\n",
     51            (shortName && *shortName ? "-" : " "), shortWidth, shortName,
     52            (longName && *longName ? "--" : "  "), longWidth, longName,
    5253            argWidth, arg,
    5354            opt->description );
  • trunk/libtransmission/transmission.h

    r7256 r7331  
    841841void tr_torrentStop( tr_torrent * torrent );
    842842
     843/** @brief Deletes the torrent data stored on disk. */
     844void tr_torrentDeleteLocalData( tr_torrent * torrent );
     845
    843846/**
    844847 * @brief Iterate through the torrents.
Note: See TracChangeset for help on using the changeset viewer.