diff --git a/macosx/BlocklistDownloader.m b/macosx/BlocklistDownloader.m index e7311cabc..42a8a49d0 100644 --- a/macosx/BlocklistDownloader.m +++ b/macosx/BlocklistDownloader.m @@ -27,7 +27,7 @@ #import "BlocklistScheduler.h" #import "PrefsController.h" -#define FILE_NAME @"blocklist.tmp" +#define FILE_NAME @"blocklist.temp" @interface BlocklistDownloader (Private) @@ -145,11 +145,13 @@ BlocklistDownloader * fDownloader = nil; NSString * urlString = [[NSUserDefaults standardUserDefaults] stringForKey: @"BlocklistURL"]; if (!urlString) urlString = @""; + else if (![urlString isEqualToString: @""] && [urlString rangeOfString: @"://"].location == NSNotFound) + urlString = [@"http://" stringByAppendingString: urlString]; NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]]; fDownload = [[NSURLDownload alloc] initWithRequest: request delegate: self]; - [fDownload setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: FILE_NAME] allowOverwrite: YES]; + [fDownload setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: FILE_NAME] allowOverwrite: NO]; } - (void) finishDownloadSuccess diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 0d84073e7..d99192b3d 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -96,6 +96,20 @@ tr_session * fHandle; [fDefaults removeObjectForKey: @"DownloadChoice"]; } + //check for old version blocklist (before 2.12) + NSDate * blocklistDate; + if ((blocklistDate = [fDefaults objectForKey: @"BlocklistLastUpdate"])) + { + [fDefaults setObject: blocklistDate forKey: @"BlocklistNewLastUpdateSuccess"]; + [fDefaults setObject: blocklistDate forKey: @"BlocklistNewLastUpdate"]; + [fDefaults removeObjectForKey: @"BlocklistLastUpdate"]; + + NSString * blocklistDir = [NSHomeDirectory() stringByAppendingPathComponent: + @"/Library/Application Support/Transmission/blocklists/"]; + [[NSFileManager defaultManager] moveItemAtPath: [blocklistDir stringByAppendingPathComponent: @"level1.bin"] + toPath: [blocklistDir stringByAppendingPathComponent: DEFAULT_BLOCKLIST_FILENAME] error: nil]; + } + //save a new random port if ([fDefaults boolForKey: @"RandomPort"]) [fDefaults setInteger: tr_sessionGetPeerPort(fHandle) forKey: @"BindPort"]; @@ -505,13 +519,6 @@ tr_session * fHandle; if (exists) { NSDate * updatedDate = [fDefaults objectForKey: @"BlocklistNewLastUpdateSuccess"]; - //old format for update date pre-2.12 - if (!updatedDate) - { - updatedDate = [fDefaults objectForKey: @"BlocklistLastUpdate"]; - [fDefaults setObject: updatedDate forKey: @"BlocklistNewLastUpdateSuccess"]; - [fDefaults removeObjectForKey: @"BlocklistLastUpdate"]; - } if (updatedDate) {