diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 319d5db86..e64e24597 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1592,7 +1592,6 @@ int trashDataFile(const char * filename) @implementation Torrent (Private) -//if a hash is given, attempt to load that; otherwise, attempt to open file at path - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib publicTorrent: (NSNumber *) publicTorrent downloadFolder: (NSString *) downloadFolder @@ -1636,29 +1635,30 @@ int trashDataFile(const char * filename) tr_ctorSetPaused(ctor, TR_FORCE, YES); tr_ctorSetPeerLimit(ctor, TR_FALLBACK, [fDefaults integerForKey: @"PeersTorrent"]); - tr_info info; int result = TR_EINVALID; if (path) - { - tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); - result = tr_torrentParse(ctor, &info); - } - if (result != TR_OK && hashString) //backup - shouldn't be needed after upgrade to 1.70 - { + result = tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); + + //backup - shouldn't be needed after upgrade to 1.62 + if (result != TR_OK && hashString) tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]); - result = tr_torrentParse(ctor, &info); - } if (result == TR_OK) { - NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] - ? fIncompleteFolder : fDownloadFolder; - tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); + tr_info info; + result = tr_torrentParse(ctor, &info); - fHandle = tr_torrentNew(ctor, NULL); + if (result == TR_OK) + { + NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] + ? fIncompleteFolder : fDownloadFolder; + tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); + + fHandle = tr_torrentNew(ctor, NULL); + } + if (result != TR_EINVALID) + tr_metainfoFree(&info); } - if (result != TR_EINVALID) - tr_metainfoFree(&info); tr_ctorFree(ctor);