]> granicus.if.org Git - transmission/commitdiff
#5005 Torrent file deleted twice when added via url
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 5 Aug 2012 03:48:13 +0000 (03:48 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 5 Aug 2012 03:48:13 +0000 (03:48 +0000)
macosx/AddWindowController.h
macosx/AddWindowController.m
macosx/Controller.m

index 6e7e7fc506ac8039556f1c6850966cf4cee9aa10..24173d95b7c509626e98dcd7a9154dc70364896c 100644 (file)
@@ -48,7 +48,7 @@
     NSString * fDestination, * fTorrentFile;
     BOOL fLockDestination;
     
-    BOOL fDeleteTorrentInitial, fDeleteEnableInitial;
+    BOOL fDeleteTorrentEnableInitially, fCanToggleDelete;
     NSInteger fGroupValue;
     
     NSTimer * fTimer;
@@ -56,7 +56,7 @@
 
 - (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path lockDestination: (BOOL) lockDestination
     controller: (Controller *) controller torrentFile: (NSString *) torrentFile
-    deleteTorrent: (BOOL) deleteTorrent canToggleDelete: (BOOL) canToggleDelete;
+    deleteTorrentCheckEnableInitially: (BOOL) deleteTorrent canToggleDelete: (BOOL) canToggleDelete; //if canToggleDelete is NO, we will also not delete the file regardless of the delete check's state (this is so it can be disabled and checked for a downloaded torrent, where the file's already deleted)
 
 - (Torrent *) torrent;
 
index 4f11dd1bb3bcb1810511fade98cf87a9019e1792..e54f6fc626126dd19a3215697a7bfce814bed6c5 100644 (file)
@@ -55,7 +55,7 @@
 
 - (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path lockDestination: (BOOL) lockDestination
     controller: (Controller *) controller torrentFile: (NSString *) torrentFile
-    deleteTorrent: (BOOL) deleteTorrent canToggleDelete: (BOOL) canToggleDelete
+    deleteTorrentCheckEnableInitially: (BOOL) deleteTorrent canToggleDelete: (BOOL) canToggleDelete
 {
     if ((self = [super initWithWindowNibName: @"AddWindow"]))
     {
@@ -67,8 +67,8 @@
         
         fTorrentFile = [[torrentFile stringByExpandingTildeInPath] retain];
         
-        fDeleteTorrentInitial = deleteTorrent;
-        fDeleteEnableInitial = canToggleDelete;
+        fDeleteTorrentEnableInitially = deleteTorrent;
+        fCanToggleDelete = canToggleDelete;
         
         fGroupValue = [torrent groupValue];
         
     
     [fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState];
     
-    [fDeleteCheck setState: fDeleteTorrentInitial ? NSOnState : NSOffState];
-    [fDeleteCheck setEnabled: fDeleteEnableInitial];
+    [fDeleteCheck setState: fDeleteTorrentEnableInitially ? NSOnState : NSOffState];
+    [fDeleteCheck setEnabled: fCanToggleDelete];
     
     if (fDestination)
         [self setDestinationPath: fDestination];
     fTimer = nil;
     [fTorrent setGroupValue: fGroupValue];
     
-    if (fTorrentFile && [fDeleteCheck state] == NSOnState)
+    if (fTorrentFile && fCanToggleDelete && [fDeleteCheck state] == NSOnState)
         [Torrent trashFile: fTorrentFile];
     
     if ([fStartCheck state] == NSOnState)
index 2ebc3dc4af8ce28bde5298b445b5334d4b934461..46217c0682b8daa178c310419f86684c7f6b1ad7 100644 (file)
@@ -926,7 +926,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         {
             AddWindowController * addController = [[AddWindowController alloc] initWithTorrent: torrent destination: location
                                                     lockDestination: lockDestination controller: self torrentFile: torrentPath
-                                                    deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
+                                                    deleteTorrentCheckEnableInitially: deleteTorrentFile canToggleDelete: canToggleDelete];
             [addController showWindow: self];
             
             if (!fAddWindows)