mirror of
https://github.com/transmission/transmission
synced 2025-02-12 09:25:03 +00:00
(trunk libT) #2393: Transmission deletes all files when moving to the same physical directory
This commit is contained in:
parent
ab7b6aa376
commit
5b19021ab1
1 changed files with 14 additions and 7 deletions
|
@ -2320,7 +2320,8 @@ struct LocationData
|
|||
static void
|
||||
setLocation( void * vdata )
|
||||
{
|
||||
int err = 0;
|
||||
tr_bool err = FALSE;
|
||||
tr_bool verify_needed = FALSE;
|
||||
struct LocationData * data = vdata;
|
||||
tr_torrent * tor = data->tor;
|
||||
const tr_bool do_move = data->move_from_old_location;
|
||||
|
@ -2358,10 +2359,15 @@ setLocation( void * vdata )
|
|||
{
|
||||
errno = 0;
|
||||
tr_torinf( tor, "moving \"%s\" to \"%s\"", oldpath, newpath );
|
||||
if( tr_moveFile( oldpath, newpath ) ) {
|
||||
err = 1;
|
||||
tr_torerr( tor, "error moving \"%s\" to \"%s\": %s",
|
||||
oldpath, newpath, tr_strerror( errno ) );
|
||||
if( rename( oldpath, newpath ) )
|
||||
{
|
||||
verify_needed = TRUE;
|
||||
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 ) )
|
||||
|
@ -2382,12 +2388,13 @@ setLocation( void * vdata )
|
|||
if( !err )
|
||||
{
|
||||
/* blow away the leftover subdirectories in the old location */
|
||||
if( do_move )
|
||||
if( do_move && verify_needed )
|
||||
tr_torrentDeleteLocalData( tor, remove );
|
||||
|
||||
/* set the new location and reverify */
|
||||
tr_torrentSetDownloadDir( tor, location );
|
||||
tr_torrentVerify( tor );
|
||||
if( verify_needed )
|
||||
tr_torrentVerify( tor );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue