]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #2531: when the user moves a torrent from one location to another, we...
authorCharles Kerr <charles@transmissionbt.com>
Tue, 27 Oct 2009 23:00:34 +0000 (23:00 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Tue, 27 Oct 2009 23:00:34 +0000 (23:00 +0000)
libtransmission/torrent.c
libtransmission/utils.c
libtransmission/utils.h

index 11bfdda099d1a0bda0222c8f1e8efb218a1927d1..de5cfa64dc81c9a5c134c2d0de15c6682432d37d 100644 (file)
@@ -2418,17 +2418,18 @@ setLocation( void * vdata )
 
                 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 ) );
-                        }
                     }
                 }
 
@@ -2454,6 +2455,10 @@ setLocation( void * vdata )
             tr_torrentSetDownloadDir( tor, location );
             if( verify_needed )
                 tr_torrentVerify( tor );
+            else if( tor->startAfterVerify ) {
+                tor->startAfterVerify = FALSE;
+                tr_torrentStart( tor );
+            }
         }
     }
 
index fec852ac896bf930b4f60128fe96af5abc6432aa..11495f10e8977f1df0655fc561ce584b9acf1a0f 100644 (file)
@@ -1355,7 +1355,7 @@ tr_strratio( char * buf, size_t buflen, double ratio, const char * infinity )
 ***/
 
 int
-tr_moveFile( const char * oldpath, const char * newpath )
+tr_moveFile( const char * oldpath, const char * newpath, tr_bool * renamed )
 {
     int in;
     int out;
@@ -1385,9 +1385,14 @@ tr_moveFile( const char * oldpath, const char * newpath )
             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 );
index 7a367573e5444c6cc3e5b552c8cdd08641f98ccf..bc509c8981007a5d43f1d667674549e91fe50b42 100644 (file)
@@ -419,7 +419,7 @@ struct tm * tr_localtime_r( const time_t *_clock, struct tm *_result );
 
 
 /** 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