]> granicus.if.org Git - transmission/commitdiff
delete the torrent file right after it finishes downloading and is opened (when openi...
authorMitchell Livingston <livings124@transmissionbt.com>
Thu, 26 Jun 2008 03:50:21 +0000 (03:50 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Thu, 26 Jun 2008 03:50:21 +0000 (03:50 +0000)
macosx/Controller.h
macosx/Controller.m

index 3b2577a73bc9b9da86e217d1421048707d1b5005..315be8495662b262cc2da4e0571af7a70184a63d 100644 (file)
@@ -113,7 +113,6 @@ typedef enum
     NSTimer                         * fAutoImportTimer;
     
     NSMutableDictionary             * fPendingTorrentDownloads;
-    NSMutableArray                  * fTempTorrentFiles;
     
     BOOL                            fSoundPlaying;
 }
index 5d174e1c1cd9bbb57d677dc22701db82f4ccd7b5..20a1eb15814923851d3e323d897f1de19b0e9e94 100644 (file)
@@ -568,25 +568,15 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     {
         NSEnumerator * downloadEnumerator = [[fPendingTorrentDownloads allValues] objectEnumerator];
         NSDictionary * downloadDict;
-        NSURLDownload * download;
         while ((downloadDict = [downloadEnumerator nextObject]))
         {
-            download = [downloadDict objectForKey: @"Download"];
+            NSURLDownload * download = [downloadDict objectForKey: @"Download"];
             [download cancel];
             [download release];
         }
         [fPendingTorrentDownloads removeAllObjects];
     }
     
-    //remove all remaining torrent files in the temporary directory
-    if (fTempTorrentFiles)
-    {
-        NSEnumerator * torrentEnumerator = [fTempTorrentFiles objectEnumerator];
-        NSString * path;
-        while ((path = [torrentEnumerator nextObject]))
-            [[NSFileManager defaultManager] removeFileAtPath: path handler: nil];
-    }
-    
     //remember window states and close all windows
     [fDefaults setBool: [[fInfoController window] isVisible] forKey: @"InfoVisible"];
     [[NSApp windows] makeObjectsPerformSelector: @selector(close)];
@@ -609,7 +599,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [fAutoImportedNames release];
     [fPendingTorrentDownloads release];
-    [fTempTorrentFiles release];
     
     //complete cleanup
     tr_sessionClose(fLib);
@@ -673,6 +662,12 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
         [error localizedDescription]], NSLocalizedString(@"OK", "Torrent download failed -> button"), nil, nil);
     
     [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
+    if ([fPendingTorrentDownloads count] == 0)
+    {
+        [fPendingTorrentDownloads release];
+        fPendingTorrentDownloads = nil;
+    }
+    
     [download release];
 }
 
@@ -682,13 +677,16 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     [self openFiles: [NSArray arrayWithObject: path] addType: ADD_URL forcePath: nil];
     
+    [[NSFileManager defaultManager] removeFileAtPath: path handler: nil]; //delete the torrent file after opening
+    
     [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
-    [download release];
+    if ([fPendingTorrentDownloads count] == 0)
+    {
+        [fPendingTorrentDownloads release];
+        fPendingTorrentDownloads = nil;
+    }
     
-    //delete temp torrent file on quit
-    if (!fTempTorrentFiles)
-        fTempTorrentFiles = [[NSMutableArray alloc] init];
-    [fTempTorrentFiles addObject: path];
+    [download release];
 }
 
 - (void) application: (NSApplication *) app openFiles: (NSArray *) filenames