Changeset 1576


Ignore:
Timestamp:
Mar 22, 2007, 6:07:22 PM (15 years ago)
Author:
joshe
Message:

Optionally return the info hash after attempting to load a duplicate torrent.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/beos/TRWindow.cpp

    r1564 r1576  
    161161                        // Try adding the torrent to the engine.
    162162                        int error;
    163                         tr_torrent_t *nTorrent = tr_torrentInit(engine, path.Path(), 0, &error);
     163                        tr_torrent_t *nTorrent = tr_torrentInit(engine, path.Path(), NULL, 0, &error);
    164164                        if (nTorrent != NULL && Lock()) { // Success. Add the TRTorrent item.
    165165                                transfers->AddItem(new TRTransfer(path.Path(), node, nTorrent));
  • trunk/cli/transmissioncli.c

    r1564 r1576  
    127127
    128128    /* Open and parse torrent file */
    129     if( !( tor = tr_torrentInit( h, torrentPath, 0, &error ) ) )
     129    if( !( tor = tr_torrentInit( h, torrentPath, NULL, 0, &error ) ) )
    130130    {
    131131        printf( "Failed opening torrent file `%s'\n", torrentPath );
  • trunk/gtk/tr_torrent.c

    r1504 r1576  
    279279    handle = tr_torrentInitSaved(back, torrent, 0, &errcode);
    280280  else
    281     handle = tr_torrentInit(back, torrent, trflags, &errcode);
     281    handle = tr_torrentInit(back, torrent, NULL, trflags, &errcode);
    282282
    283283  if(NULL == handle) {
  • trunk/libtransmission/torrent.c

    r1564 r1576  
    3030 **********************************************************************/
    3131static tr_torrent_t * torrentRealInit( tr_handle_t *, tr_torrent_t * tor,
    32                                        int flags, int * error );
     32                                       uint8_t *, int flags, int * error );
    3333static void torrentReallyStop( tr_torrent_t * );
    3434static void downloadLoop( void * );
     
    5555
    5656tr_torrent_t * tr_torrentInit( tr_handle_t * h, const char * path,
    57                                int flags, int * error )
     57                               uint8_t * hash, int flags, int * error )
    5858{
    5959    tr_torrent_t  * tor = calloc( sizeof( tr_torrent_t ), 1 );
     
    6868    }
    6969
    70     return torrentRealInit( h, tor, flags, error );
     70    return torrentRealInit( h, tor, hash, flags, error );
    7171}
    7272
     
    8484    }
    8585
    86     return torrentRealInit( h, tor, ( TR_FLAG_SAVE | flags ), error );
     86    return torrentRealInit( h, tor, NULL, ( TR_FLAG_SAVE | flags ), error );
    8787}
    8888
     
    9494 **********************************************************************/
    9595static tr_torrent_t * torrentRealInit( tr_handle_t * h, tr_torrent_t * tor,
    96                                        int flags, int * error )
     96                                       uint8_t * hash, int flags, int * error )
    9797{
    9898    tr_torrent_t  * tor_tmp;
     
    111111                     SHA_DIGEST_LENGTH ) )
    112112        {
     113            if( NULL != hash )
     114            {
     115                memcpy( hash, tor->info.hash, SHA_DIGEST_LENGTH );
     116            }
    113117            *error = TR_EDUPLICATE;
    114118            tr_metainfoFree( &tor->info );
  • trunk/libtransmission/transmission.h

    r1564 r1576  
    194194 * tr_torrentInit
    195195 ***********************************************************************
    196  * Opens and parses torrent file at 'path'. If the file exists and is a
    197  * valid torrent file, returns an handle and adds it to the list of
     196 * Opens and parses torrent file at 'path'. If the file exists and is
     197 * a valid torrent file, returns an handle and adds it to the list of
    198198 * torrents (but doesn't start it). Returns NULL and sets *error
    199  * otherwise.  If the TR_FLAG_SAVE flag is passed then a copy of the
    200  * torrent file will be saved.
     199 * otherwise. If hash is not NULL and the torrent is already loaded
     200 * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag
     201 * is passed then a copy of the torrent file will be saved.
    201202 **********************************************************************/
    202203#define TR_EINVALID     1
     
    205206#define TR_EOTHER       666
    206207tr_torrent_t * tr_torrentInit( tr_handle_t *, const char * path,
    207                                int flags, int * error );
     208                               uint8_t * hash, int flags, int * error );
    208209
    209210/***********************************************************************
     
    211212 ***********************************************************************
    212213 * Opens and parses a torrent file as with tr_torrentInit, only taking
    213  * the hash string of a saved torrent file instead of a filename.  There
     214 * the hash string of a saved torrent file instead of a filename. There
    214215 * are currently no valid flags for this function.
    215216 **********************************************************************/
  • trunk/macosx/Controller.m

    r1565 r1576  
    703703   
    704704        torrentPath = [[files objectAtIndex: 0] retain];
    705         tempTor = tr_torrentInit(fLib, [torrentPath UTF8String], 0, &error);
     705        tempTor = tr_torrentInit(fLib, [torrentPath UTF8String], NULL, 0, &error);
    706706       
    707707        [files removeObjectAtIndex: 0];
     
    18181818    while ((file = [enumerator nextObject]))
    18191819    {
    1820         tr_torrent_t * tempTor = tr_torrentInit(fLib, [file UTF8String], 0, &error);
     1820        tr_torrent_t * tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error);
    18211821       
    18221822        if (tempTor)
  • trunk/macosx/Torrent.m

    r1575 r1576  
    12211221   
    12221222    if (!fHandle && path)
    1223         fHandle = tr_torrentInit(fLib, [path UTF8String], TR_FLAG_SAVE, & error);
     1223        fHandle = tr_torrentInit(fLib, [path UTF8String], NULL, TR_FLAG_SAVE, & error);
    12241224
    12251225    if (!fHandle)
Note: See TracChangeset for help on using the changeset viewer.