From c36a007cd4ce3271dddd18013017b7c3953e1873 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 22 May 2009 02:26:02 +0000 Subject: [PATCH] remove a little redundant code from the last commit --- macosx/Torrent.m | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 3ab910abb..319d5db86 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1637,33 +1637,29 @@ int trashDataFile(const char * filename) tr_ctorSetPeerLimit(ctor, TR_FALLBACK, [fDefaults integerForKey: @"PeersTorrent"]); tr_info info; + int result = TR_EINVALID; if (path) { tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); - if (tr_torrentParse(ctor, &info) == TR_OK) - { - NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] - ? fIncompleteFolder : fDownloadFolder; - tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); - - fHandle = tr_torrentNew(ctor, NULL); - } - tr_metainfoFree(&info); + result = tr_torrentParse(ctor, &info); } - if (!fHandle && hashString) //backup - shouldn't be needed after upgrade to 1.70 + if (result != TR_OK && hashString) //backup - shouldn't be needed after upgrade to 1.70 { tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]); - if (tr_torrentParse(ctor, &info) == TR_OK) - { - NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] - ? fIncompleteFolder : fDownloadFolder; - tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); - - fHandle = tr_torrentNew(ctor, NULL); - } - tr_metainfoFree(&info); + 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]); + + fHandle = tr_torrentNew(ctor, NULL); + } + if (result != TR_EINVALID) + tr_metainfoFree(&info); + tr_ctorFree(ctor); if (!fHandle)