Changeset 8470


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

save internal torrent path to history, and prefer that over the hash when loading on startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.m

    r8439 r8470  
    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 forcePause: (BOOL) pause
    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",
     
    15921594
    15931595//if a hash is given, attempt to load that; otherwise, attempt to open file at path
    1594 - (id) initWithHash: (NSString *) hashString path: (NSString *) path torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
     1596- (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib
    15951597        publicTorrent: (NSNumber *) publicTorrent
    15961598        downloadFolder: (NSString *) downloadFolder
     
    16361638       
    16371639        tr_info info;
    1638         if (hashString)
    1639         {
    1640             tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]);
     1640        if (path)
     1641        {
     1642            tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]);
    16411643            if (tr_torrentParse(ctor, &info) == TR_OK)
    16421644            {
     
    16491651            tr_metainfoFree(&info);
    16501652        }
    1651         if (!fHandle && path)
    1652         {
    1653             tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]);
     1653        if (!fHandle && hashString) //backup - shouldn't be needed after upgrade to 1.70
     1654        {
     1655            tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]);
    16541656            if (tr_torrentParse(ctor, &info) == TR_OK)
    16551657            {
Note: See TracChangeset for help on using the changeset viewer.