if( do_move )
{
+ tr_bool renamed = FALSE;
errno = 0;
tr_torinf( tor, "moving \"%s\" to \"%s\"", oldpath, newpath );
- if( rename( oldpath, newpath ) )
+ if( tr_moveFile( oldpath, newpath, &renamed ) )
+ {
+ err = TRUE;
+ tr_torerr( tor, "error moving \"%s\" to \"%s\": %s",
+ oldpath, newpath, tr_strerror( errno ) );
+ }
+ else if( !renamed )
{
verify_needed = TRUE;
- if( tr_moveFile( oldpath, newpath ) )
- {
- err = TRUE;
- tr_torerr( tor, "error moving \"%s\" to \"%s\": %s",
- oldpath, newpath, tr_strerror( errno ) );
- }
}
}
tr_torrentSetDownloadDir( tor, location );
if( verify_needed )
tr_torrentVerify( tor );
+ else if( tor->startAfterVerify ) {
+ tor->startAfterVerify = FALSE;
+ tr_torrentStart( tor );
+ }
}
}
***/
int
-tr_moveFile( const char * oldpath, const char * newpath )
+tr_moveFile( const char * oldpath, const char * newpath, tr_bool * renamed )
{
int in;
int out;
return i;
}
- /* they might be on the same filesystem... */
- if( !rename( oldpath, newpath ) )
- return 0;
+ /* they might be on the same filesystem... */
+ {
+ const int i = rename( oldpath, newpath );
+ if( renamed != NULL )
+ *renamed = i == 0;
+ if( !i )
+ return 0;
+ }
/* copy the file */
in = tr_open_file_for_scanning( oldpath );
/** on success, return 0. on failure, return -1 and set errno */
-int tr_moveFile( const char * oldpath, const char * newpath );
+int tr_moveFile( const char * oldpath, const char * newpath, tr_bool * renamed );
#ifdef __cplusplus