Changeset 8472


Ignore:
Timestamp:
May 22, 2009, 2:40:14 AM (12 years ago)
Author:
livings124
Message:

(1.6x) backport r8470-r8471

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6x/macosx/Torrent.m

    r8260 r8472  
    3131@interface Torrent (Private)
    3232
    33 - (id) initWithHash: (NSString *) hashString path: (NSString *) path torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
     33- (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
    3434        publicTorrent: (NSNumber *) publicTorrent
    3535        downloadFolder: (NSString *) downloadFolder
     
    8484        lib: (tr_session *) lib
    8585{
    86     self = [self initWithHash: nil path: path torrentStruct: NULL lib: lib
     86    self = [self initWithPath: path hash: nil torrentStruct: NULL lib: lib
    8787            publicTorrent: torrentDelete != TORRENT_FILE_DEFAULT ? [NSNumber numberWithBool: torrentDelete == TORRENT_FILE_SAVE] : nil
    8888            downloadFolder: location
     
    108108- (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib
    109109{
    110     self = [self initWithHash: nil path: nil torrentStruct: torrentStruct lib: lib
     110    self = [self initWithPath: nil hash: nil torrentStruct: torrentStruct lib: lib
    111111            publicTorrent: [NSNumber numberWithBool: NO]
    112112            downloadFolder: location
     
    119119- (id) initWithHistory: (NSDictionary *) history lib: (tr_session *) lib
    120120{
    121     self = [self initWithHash: [history objectForKey: @"TorrentHash"]
    122                 path: [history objectForKey: @"TorrentPath"] torrentStruct: NULL lib: lib
     121    self = [self initWithPath: [history objectForKey: @"InternalTorrentPath"]
     122                hash: [history objectForKey: @"TorrentHash"]
     123                torrentStruct: NULL lib: lib
    123124                publicTorrent: [history objectForKey: @"PublicCopy"]
    124125                downloadFolder: [history objectForKey: @"DownloadFolder"]
     
    169170{
    170171    NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
     172                    [self torrentLocation], @"InternalTorrentPath",
     173                    [self hashString], @"TorrentHash",
    171174                    [NSNumber numberWithBool: fPublicTorrent], @"PublicCopy",
    172                     [self hashString], @"TorrentHash",
    173175                    fDownloadFolder, @"DownloadFolder",
    174176                    [NSNumber numberWithBool: fUseIncompleteFolder], @"UseIncompleteFolder",
     
    15861588@implementation Torrent (Private)
    15871589
    1588 //if a hash is given, attempt to load that; otherwise, attempt to open file at path
    1589 - (id) initWithHash: (NSString *) hashString path: (NSString *) path torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
     1590- (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
    15901591        publicTorrent: (NSNumber *) publicTorrent
    15911592        downloadFolder: (NSString *) downloadFolder
     
    16311632       
    16321633        tr_info info;
    1633         if (hashString)
     1634        int result = TR_EINVALID;
     1635        if (path)
     1636        {
     1637            tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]);
     1638            result = tr_torrentParse(ctor, &info);
     1639        }
     1640        if (result != TR_OK && hashString) //backup - shouldn't be needed after upgrade to 1.70
    16341641        {
    16351642            tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]);
    1636             if (tr_torrentParse(ctor, &info) == TR_OK)
    1637             {
    1638                 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]]
    1639                                                     ? fIncompleteFolder : fDownloadFolder;
    1640                 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]);
    1641                
    1642                 fHandle = tr_torrentNew(ctor, NULL);
    1643             }
     1643            result = tr_torrentParse(ctor, &info);
     1644        }
     1645       
     1646        if (result == TR_OK)
     1647        {
     1648            NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]]
     1649                                                ? fIncompleteFolder : fDownloadFolder;
     1650            tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]);
     1651           
     1652            fHandle = tr_torrentNew(ctor, NULL);
     1653        }
     1654        if (result != TR_EINVALID)
    16441655            tr_metainfoFree(&info);
    1645         }
    1646         if (!fHandle && path)
    1647         {
    1648             tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]);
    1649             if (tr_torrentParse(ctor, &info) == TR_OK)
    1650             {
    1651                 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]]
    1652                                                     ? fIncompleteFolder : fDownloadFolder;
    1653                 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]);
    1654                
    1655                 fHandle = tr_torrentNew(ctor, NULL);
    1656             }
    1657             tr_metainfoFree(&info);
    1658         }
    16591656       
    16601657        tr_ctorFree(ctor);
Note: See TracChangeset for help on using the changeset viewer.