Changeset 8389 for trunk/libtransmission/torrent.c
- Timestamp:
- May 13, 2009, 3:54:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r8257 r8389 240 240 break; 241 241 242 case TR_RATIOLIMIT_UNLIMITED:242 default: /* TR_RATIOLIMIT_UNLIMITED */ 243 243 isLimited = FALSE; 244 244 break; … … 735 735 736 736 void 737 tr_torrentSetDownloadDir( tr_torrent * tor, 738 const char * path ) 737 tr_torrentSetDownloadDir( tr_torrent * tor, const char * path ) 739 738 { 740 739 assert( tr_isTorrent( tor ) ); … … 1236 1235 1237 1236 static void 1238 torrentStart( tr_torrent * tor, 1239 int reloadProgress ) 1237 torrentStart( tr_torrent * tor, int reloadProgress ) 1240 1238 { 1241 1239 assert( tr_isTorrent( tor ) ); … … 1273 1271 assert( tr_isTorrent( tor ) ); 1274 1272 tr_torrentRecheckCompleteness( tor ); 1273 1274 if( tor->startAfterVerify ) 1275 { 1276 tor->startAfterVerify = FALSE; 1277 tr_torrentStart( tor ); 1278 } 1275 1279 } 1276 1280 … … 1287 1291 { 1288 1292 assert( tr_isTorrent( tor ) ); 1289 1293 tr_globalLock( tor->session ); 1294 1295 /* if the torrent's already being verified, stop it */ 1290 1296 tr_verifyRemove( tor ); 1291 1297 1292 tr_globalLock( tor->session ); 1293 1298 /* if the torrent's running, stop it & set the restart-after-verify flag */ 1299 if( tor->isRunning ) { 1300 tr_torrentStop( tor ); 1301 tor->startAfterVerify = TRUE; 1302 } 1303 1304 /* add the torrent to the recheck queue */ 1294 1305 tr_torrentUncheck( tor ); 1295 1306 tr_verifyAdd( tor, torrentRecheckDoneCB ); … … 1316 1327 evbuffer_free( buf ); 1317 1328 } 1318 1319 1329 1320 1330 static void … … 2199 2209 ***/ 2200 2210 2211 struct LocationData 2212 { 2213 tr_bool move_from_old_location; 2214 tr_bool * setme_done; 2215 char * location; 2216 tr_torrent * tor; 2217 }; 2218 2219 static void 2220 setLocation( void * vdata ) 2221 { 2222 struct LocationData * data = vdata; 2223 tr_torrent * tor = data->tor; 2224 const tr_bool do_move = data->move_from_old_location; 2225 const char * location = data->location; 2226 2227 assert( tr_isTorrent( tor ) ); 2228 2229 if( strcmp( location, tor->downloadDir ) ) 2230 { 2231 tr_file_index_t i; 2232 2233 /* bad idea to move files while they're being verified... */ 2234 tr_verifyRemove( tor ); 2235 2236 /* if the torrent is running, stop it and set a flag to 2237 * restart after we're done */ 2238 if( tor->isRunning ) 2239 { 2240 tr_torrentStop( tor ); 2241 tor->startAfterVerify = TRUE; 2242 } 2243 2244 /* try to move the files. 2245 * FIXME: there are still all kinds of nasty cases, like what 2246 * if the target directory runs out of space halfway through... */ 2247 for( i=0; i<tor->info.fileCount; ++i ) 2248 { 2249 struct stat sb; 2250 char * oldpath = tr_buildPath( tor->downloadDir, tor->info.files[i].name, NULL ); 2251 char * newpath = tr_buildPath( location, tor->info.files[i].name, NULL ); 2252 2253 2254 if( do_move && !stat( oldpath, &sb ) ) 2255 { 2256 tr_moveFile( oldpath, newpath ); 2257 tr_torinf( tor, "moving \"%s\" to \"%s\"", oldpath, newpath ); 2258 } 2259 else if( !stat( newpath, &sb ) ) 2260 { 2261 tr_torinf( tor, "found \"%s\"", newpath ); 2262 } 2263 2264 tr_free( newpath ); 2265 tr_free( oldpath ); 2266 } 2267 2268 /* blow away the leftover subdirectories in the old location */ 2269 tr_torrentDeleteLocalData( tor, unlink ); 2270 2271 /* set the new location and reverify */ 2272 tr_torrentSetDownloadDir( tor, location ); 2273 tr_torrentVerify( tor ); 2274 } 2275 2276 if( data->setme_done ) 2277 *data->setme_done = TRUE; 2278 2279 /* cleanup */ 2280 tr_free( data->location ); 2281 tr_free( data ); 2282 } 2283 2284 void 2285 tr_torrentSetLocation( tr_torrent * tor, 2286 const char * location, 2287 tr_bool move_from_old_location, 2288 tr_bool * setme_done ) 2289 { 2290 struct LocationData * data; 2291 2292 assert( tr_isTorrent( tor ) ); 2293 2294 if( setme_done ) 2295 *setme_done = FALSE; 2296 2297 /* run this in the libtransmission thread */ 2298 data = tr_new( struct LocationData, 1 ); 2299 data->tor = tor; 2300 data->location = tr_strdup( location ); 2301 data->move_from_old_location = move_from_old_location; 2302 data->setme_done = setme_done; 2303 tr_runInEventThread( tor->session, setLocation, data ); 2304 } 2305 2306 /*** 2307 **** 2308 ***/ 2309 2201 2310 void 2202 2311 tr_torrentCheckSeedRatio( tr_torrent * tor )
Note: See TracChangeset
for help on using the changeset viewer.