Changeset 11372


Ignore:
Timestamp:
Nov 1, 2010, 12:06:40 AM (12 years ago)
Author:
livings124
Message:

automatically upgrade the old blocklist file name to the new name

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BlocklistDownloader.m

    r11371 r11372  
    2828#import "PrefsController.h"
    2929
    30 #define FILE_NAME @"blocklist.tmp"
     30#define FILE_NAME @"blocklist.temp"
    3131
    3232@interface BlocklistDownloader (Private)
     
    146146    if (!urlString)
    147147        urlString = @"";
     148    else if (![urlString isEqualToString: @""] && [urlString rangeOfString: @"://"].location == NSNotFound)
     149        urlString = [@"http://" stringByAppendingString: urlString];
    148150   
    149151    NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]];
    150152   
    151153    fDownload = [[NSURLDownload alloc] initWithRequest: request delegate: self];
    152     [fDownload setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: FILE_NAME] allowOverwrite: YES];
     154    [fDownload setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: FILE_NAME] allowOverwrite: NO];
    153155}
    154156
  • trunk/macosx/PrefsController.m

    r11371 r11372  
    9797        }
    9898       
     99        //check for old version blocklist (before 2.12)
     100        NSDate * blocklistDate;
     101        if ((blocklistDate = [fDefaults objectForKey: @"BlocklistLastUpdate"]))
     102        {
     103            [fDefaults setObject: blocklistDate forKey: @"BlocklistNewLastUpdateSuccess"];
     104            [fDefaults setObject: blocklistDate forKey: @"BlocklistNewLastUpdate"];
     105            [fDefaults removeObjectForKey: @"BlocklistLastUpdate"];
     106           
     107            NSString * blocklistDir = [NSHomeDirectory() stringByAppendingPathComponent:
     108                                        @"/Library/Application Support/Transmission/blocklists/"];
     109            [[NSFileManager defaultManager] moveItemAtPath: [blocklistDir stringByAppendingPathComponent: @"level1.bin"]
     110                toPath: [blocklistDir stringByAppendingPathComponent: DEFAULT_BLOCKLIST_FILENAME] error: nil];
     111        }
     112       
    99113        //save a new random port
    100114        if ([fDefaults boolForKey: @"RandomPort"])
     
    506520    {
    507521        NSDate * updatedDate = [fDefaults objectForKey: @"BlocklistNewLastUpdateSuccess"];
    508         //old format for update date pre-2.12
    509         if (!updatedDate)
    510         {
    511             updatedDate = [fDefaults objectForKey: @"BlocklistLastUpdate"];
    512             [fDefaults setObject: updatedDate forKey: @"BlocklistNewLastUpdateSuccess"];
    513             [fDefaults removeObjectForKey: @"BlocklistLastUpdate"];
    514         }
    515522       
    516523        if (updatedDate)
Note: See TracChangeset for help on using the changeset viewer.