1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-12 17:34:40 +00:00

(trunk libT) #2393: Transmission deletes all files when moving to the same physical directory

This commit is contained in:
Charles Kerr 2009-10-07 03:49:55 +00:00
parent ab7b6aa376
commit 5b19021ab1

View file

@ -2320,7 +2320,8 @@ struct LocationData
static void static void
setLocation( void * vdata ) setLocation( void * vdata )
{ {
int err = 0; tr_bool err = FALSE;
tr_bool verify_needed = FALSE;
struct LocationData * data = vdata; struct LocationData * data = vdata;
tr_torrent * tor = data->tor; tr_torrent * tor = data->tor;
const tr_bool do_move = data->move_from_old_location; const tr_bool do_move = data->move_from_old_location;
@ -2358,10 +2359,15 @@ setLocation( void * vdata )
{ {
errno = 0; errno = 0;
tr_torinf( tor, "moving \"%s\" to \"%s\"", oldpath, newpath ); tr_torinf( tor, "moving \"%s\" to \"%s\"", oldpath, newpath );
if( tr_moveFile( oldpath, newpath ) ) { if( rename( oldpath, newpath ) )
err = 1; {
tr_torerr( tor, "error moving \"%s\" to \"%s\": %s", verify_needed = TRUE;
oldpath, newpath, tr_strerror( errno ) ); if( tr_moveFile( oldpath, newpath ) )
{
err = TRUE;
tr_torerr( tor, "error moving \"%s\" to \"%s\": %s",
oldpath, newpath, tr_strerror( errno ) );
}
} }
} }
else if( !stat( newpath, &sb ) ) else if( !stat( newpath, &sb ) )
@ -2382,12 +2388,13 @@ setLocation( void * vdata )
if( !err ) if( !err )
{ {
/* blow away the leftover subdirectories in the old location */ /* blow away the leftover subdirectories in the old location */
if( do_move ) if( do_move && verify_needed )
tr_torrentDeleteLocalData( tor, remove ); tr_torrentDeleteLocalData( tor, remove );
/* set the new location and reverify */ /* set the new location and reverify */
tr_torrentSetDownloadDir( tor, location ); tr_torrentSetDownloadDir( tor, location );
tr_torrentVerify( tor ); if( verify_needed )
tr_torrentVerify( tor );
} }
} }