Skip to content

Commit

Permalink
Don't "remove any old .torrent and .resume files" until we're sure th…
Browse files Browse the repository at this point in the history
…at 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` .
  • Loading branch information
cfpp2p committed Nov 10, 2016
1 parent fa96ec0 commit 465505f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libtransmission/torrent-magnet.c
Expand Up @@ -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 ) )
{
Expand All @@ -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;
Expand Down

3 comments on commit 465505f

@cfpp2p
Copy link
Owner

@cfpp2p cfpp2p commented on 465505f Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see important related commit: fa96ec0

@cfpp2p
Copy link
Owner

@cfpp2p cfpp2p commented on 465505f Nov 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceeding maxMagnetBadPiece prevents trying again and again downloading magnet metadata forever.

Doesn't make sense to me: Since the official transmission inception of Magnet, BEP # 9 support ( https://trac.transmissionbt.com/browser/trunk/libtransmission/torrent-magnet.c?rev=9550#L186 ) through current official transmission trunk that, after fully acquiring a magnet torrent's info dictionary metadata AND successfully matching info.hash tr_sha1() checksum test why the * drat. * section ( "metadata error; trying again" ) would ever need to be again processed. Trying again only makes sense to me if the checksum fails, not for a failed parse of valid SHA-1 metadata. At any rate, exceeding maxMagnetBadPiece prevents trying again and again downloading magnet metadata forever.

@cfpp2p
Copy link
Owner

@cfpp2p cfpp2p commented on 465505f Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would ever need to be again processed

Fixed that here:
a5561b7

Please sign in to comment.