]> granicus.if.org Git - transmission/commitdiff
restore the check of moving a folder into itself
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 25 Oct 2009 03:05:25 +0000 (03:05 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 25 Oct 2009 03:05:25 +0000 (03:05 +0000)
macosx/Torrent.m

index 312027e3b10a4f44a15b0894855ae7830d5b2bf8..057bc85c57e06aa63fbc3d8909af725714f76449 100644 (file)
@@ -430,20 +430,17 @@ int trashDataFile(const char * filename)
 
 - (void) moveTorrentDataFileTo: (NSString *) folder
 {
-    #warning fix
-    /*NSString * oldFolder = [self downloadFolder];
+    NSString * oldFolder = [self currentDirectory];
     if ([oldFolder isEqualToString: folder])
         return;
     
     //check if moving inside itself
     NSArray * oldComponents = [oldFolder pathComponents],
             * newComponents = [folder pathComponents];
-    NSInteger count;
+    const NSInteger oldCount = [oldComponents count];
     
-    if ((count = [oldComponents count]) < [newComponents count]
-            && [[newComponents objectAtIndex: count] isEqualToString: [self name]]
-            && [oldComponents isEqualToArray:
-                    [newComponents objectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, count)]]])
+    if (oldCount < [newComponents count] && [[newComponents objectAtIndex: oldCount] isEqualToString: [self name]]
+        && [folder hasPrefix: oldFolder])
     {
         NSAlert * alert = [[NSAlert alloc] init];
         [alert setMessageText: NSLocalizedString(@"A folder cannot be moved to inside itself.",
@@ -457,7 +454,7 @@ int trashDataFile(const char * filename)
         [alert release];
         
         return;
-    }*/
+    }
     
     int status;
     tr_torrentSetLocation(fHandle, [folder UTF8String], YES, NULL, &status);