mirror of
https://github.com/transmission/transmission
synced 2025-02-22 22:20:39 +00:00
automatically upgrade the old blocklist file name to the new name
This commit is contained in:
parent
c124077cce
commit
c6b0ee7c5c
2 changed files with 18 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue