From 465505f4f59a08385d305b3cb2c01819df9cd7e5 Mon Sep 17 00:00:00 2001 From: cfpp2p Date: Thu, 10 Nov 2016 06:47:02 -0500 Subject: [PATCH] Don't "remove any old .torrent and .resume files" until we're sure that we have "success". This way magnets with "metadata error; trying again" actually do try again and also these magnets will now be available after daemon restart. Previously, whenever "trying again" tr_bencLoadFile() might fail indefinitely and therefore try again downloading forever because of never allowing for tr_metainfoParse() to even be tried. This bug was introduced at https://trac.transmissionbt.com/changeset/10842 when `assert( success )` was replaced by `if( success` . --- libtransmission/torrent-magnet.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libtransmission/torrent-magnet.c b/libtransmission/torrent-magnet.c index d97e540541..6ba75c15da 100644 --- a/libtransmission/torrent-magnet.c +++ b/libtransmission/torrent-magnet.c @@ -312,15 +312,11 @@ tr_torrentSetMetadataPiece( tr_torrent * tor, int piece, const void * data, in tr_info info; int infoDictLength; - /* remove any old .torrent and .resume files */ - remove( path ); - tr_torrentRemoveResume( tor ); - - dbgmsg( tor, "Saving completed metadata to \"%s\"", path ); tr_bencMergeDicts( tr_bencDictAddDict( &newMetainfo, "info", 0 ), &infoDict ); memset( &info, 0, sizeof( tr_info ) ); success = tr_metainfoParse( tor->session, &newMetainfo, &info, &hasInfo, &infoDictLength ); + dbgmsg( tor, "Parsed completed metadata info -length- %d", infoDictLength ); if( success && !tr_getBlockSize( info.pieceSize ) ) { @@ -331,6 +327,11 @@ tr_torrentSetMetadataPiece( tr_torrent * tor, int piece, const void * data, in if( success ) { + /* remove any old .torrent and .resume files */ + remove( path ); + tr_torrentRemoveResume( tor ); + + dbgmsg( tor, "Saving completed metadata to \"%s\"", path ); /* keep the new info */ tor->info = info; tor->infoDictLength = infoDictLength;