Changeset 10109


Ignore:
Timestamp:
Feb 6, 2010, 5:22:27 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #2716 "magnet torrents not being saved after quit" -- fix regression reported by RolCol? @ http://trac.transmissionbt.com/ticket/2716#comment:8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent-magnet.c

    r10084 r10109  
    1313#include <assert.h>
    1414#include <event.h> /* struct evbuffer */
     15#include <stdio.h> /* remove() */
    1516
    1617#include "transmission.h"
     
    1920#include "magnet.h"
    2021#include "metainfo.h"
     22#include "resume.h"
    2123#include "torrent.h"
    2224#include "torrent-magnet.h"
     
    192194            if(( metainfoParsed = !err ))
    193195            {
    194                 /* yay we have bencoded metainfo... merge it into our .torrnet file */
     196                /* yay we have bencoded metainfo... merge it into our .torrent file */
    195197                tr_benc newMetainfo;
    196                 const char * path = tor->info.torrent;
     198                char * path = tr_strdup( tor->info.torrent );
     199
    197200                if( !tr_bencLoadFile( &newMetainfo, TR_FMT_BENC, path ) )
    198201                {
     
    200203                    tr_benc * tmp;
    201204
     205                    /* remove any old .torrent and .resume files */
     206                    remove( path );
     207                    tr_torrentRemoveResume( tor );
     208
    202209                    dbgmsg( tor, "Saving completed metadata to \"%s\"", path );
    203210                    assert( !tr_bencDictFindDict( &newMetainfo, "info", &tmp ) );
    204211                    tr_bencMergeDicts( tr_bencDictAddDict( &newMetainfo, "info", 0 ), &infoDict );
    205                     tr_bencToFile( &newMetainfo, TR_FMT_BENC, path );
    206212
    207213                    success = tr_metainfoParse( tor->session, &newMetainfo, &tor->info,
     
    211217                    assert( success );
    212218
     219                    /* save the new .torrent file */
     220                    tr_bencToFile( &newMetainfo, TR_FMT_BENC, tor->info.torrent );
     221                    tr_sessionSetTorrentFile( tor->session, tor->info.hashString, tor->info.torrent );
    213222                    tr_torrentGotNewInfoDict( tor );
    214223                    tr_torrentSetDirty( tor );
     
    218227       
    219228                tr_bencFree( &infoDict );
     229                tr_free( path );
    220230            }
    221231        }
Note: See TracChangeset for help on using the changeset viewer.