Changeset 10539


Ignore:
Timestamp:
Apr 28, 2010, 11:03:38 AM (11 years ago)
Author:
livings124
Message:

when downloading the blocklist, don't explicitly overwrite an existing file

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BlocklistDownloader.h

    r9844 r10539  
    4040    BlocklistDownloaderViewController * fViewController;
    4141   
     42    NSString * fDestination;
    4243    NSUInteger fCurrentSize;
    4344    long long fExpectedSize;
  • trunk/macosx/BlocklistDownloader.m

    r9844 r10539  
    2929
    3030#define LIST_URL @"http://update.transmissionbt.com/level1.gz"
    31 #define DESTINATION [NSTemporaryDirectory() stringByAppendingPathComponent: @"level1.gz"]
     31#define FILE_NAME @"level1.gz"
    3232
    3333@interface BlocklistDownloader (Private)
     
    8080{
    8181    [fDownload release];
     82    [fDestination release];
    8283    [super dealloc];
    8384}
     
    9394    fDownloader = nil;
    9495    [self release];
     96}
     97
     98- (void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
     99{
     100    fDestination = [path retain];
    95101}
    96102
     
    140146   
    141147    fDownload = [[NSURLDownload alloc] initWithRequest: request delegate: self];
    142     [fDownload setDestination: DESTINATION allowOverwrite: YES];
     148    [fDownload setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: FILE_NAME] allowOverwrite: NO];
    143149}
    144150
     
    150156   
    151157    //process data
    152     tr_blocklistSetContent([PrefsController handle], [DESTINATION UTF8String]);
     158    NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
     159    tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
    153160   
    154161    //delete downloaded file
    155     [[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
     162    [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
    156163   
    157164    [fViewController setFinished];
Note: See TracChangeset for help on using the changeset viewer.