Ticket #1510: delete-file.diff
File delete-file.diff, 3.8 KB (added by kysucix, 12 years ago) |
---|
-
libtransmission/rpcimpl.c
140 140 tr_benc * args_in, 141 141 tr_benc * args_out UNUSED ) 142 142 { 143 int i, torrentCount; 144 tr_torrent ** torrents = getTorrents( h, args_in, &torrentCount ); 143 int i, torrentCount; 144 tr_file_index_t t; 145 int64_t deleteFile = 0; 146 tr_torrent ** torrents = getTorrents( h, args_in, &torrentCount ); 145 147 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 ); 151 if( !( status & TR_RPC_NOREMOVE ) ) 152 tr_torrentRemove( tor ); 153 } 154 tr_free( torrents ); 155 return NULL; 148 for( i = 0; i < torrentCount; ++i ) 149 { 150 tr_torrent * tor = torrents[i]; 151 const tr_rpc_callback_status status = notify( 152 h, TR_RPC_TORRENT_REMOVING, tor ); 153 if( !( status & TR_RPC_NOREMOVE ) ) 154 { 155 /* 156 * if delete-file = 1 delete from disk every file in the torrent 157 * being removed 158 */ 159 if( tr_bencDictFindInt( args_in, "delete-file", &deleteFile ) && deleteFile == 1) 160 { 161 const tr_file_index_t n = tor->info.fileCount; 162 for( t = 0; t < n; t++ ) 163 { 164 char *torrent_url; 165 tr_file *f = &tor -> info.files[t]; 166 torrent_url = tr_buildPath( tor -> downloadDir, f->name, NULL ); 167 tr_dbg ( "Deleting %s", torrent_url); 168 remove(torrent_url); /* is it platform safe? */ 169 tr_free (torrent_url); 170 } 171 } 172 tr_torrentRemove( tor ); 173 } 174 } 175 tr_free( torrents ); 176 return NULL; 156 177 } 157 178 158 179 static const char* -
daemon/remote.c
99 99 "pl", 1, "<files>" }, 100 100 { 'r', "remove", "Remove the current torrent(s)", 101 101 "r", 0, NULL }, 102 { 'R', "remove-and-delete", "Remove the current torrent(s) and delete file(s) from disk", 103 "R", 0, NULL }, 102 104 { 's', "start", "Start the current torrent(s)", 103 105 "s", 0, NULL }, 104 106 { 'S', "stop", "Stop the current torrent(s)", … … 409 411 addIdArg( args, id ); 410 412 break; 411 413 414 case 'R': 415 tr_bencDictAddStr( &top, "method", "torrent-remove" ); 416 addIdArg( args, id ); 417 tr_bencDictAddInt( args, "delete-file", 1 ); 418 break; 419 412 420 case 's': 413 421 tr_bencDictAddStr( &top, "method", "torrent-start" ); 414 422 addIdArg( args, id ); -
doc/rpc-spec.txt
73 73 "torrent-stop" | tr_torrentStop 74 74 "torrent-verify" | tr_torrentVerify 75 75 76 Request arguments: "ids", a list of torrent id numbers, sha1 hash strings,76 Request arguments: (1) "ids", a list of torrent id numbers, sha1 hash strings, 77 77 or both. These are the torrents that the request will 78 78 be applied to. If "ids" is ommitted, the request is 79 79 applied to all torrents. 80 (2) torrent-remove accept the following optional 81 argument: 80 82 83 string | value type & description 84 ---------------------------+------------------------------------------------- 85 "delete-file" | 'boolean' true to delete files too 86 81 87 Response arguments: none 82 88 83 89 3.2. Torrent Mutators