Changeset 2210


Ignore:
Timestamp:
Jun 27, 2007, 11:22:09 PM (15 years ago)
Author:
charles
Message:

simplify tr_torrentParse() based on BWM's feedback

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2207 r2210  
    270270        return TR_EDUPLICATE;
    271271
    272     if( pathIsInUse( h, destination, info->name ) )
    273         return TR_ERROR_IO_DUP_DOWNLOAD;
     272    if( destination && pathIsInUse( h, destination, info->name ) )
     273        return TR_EDUPLICATE;
    274274
    275275    return TR_OK;
     
    280280                 const char         * path,
    281281                 const char         * destination,
    282                  tr_info_t          * setme_info,
    283                  int                * setme_canAdd )
     282                 tr_info_t          * setme_info )
    284283{
    285284    int ret;
     
    291290    ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE );
    292291
    293     if( setme_canAdd )
    294        *setme_canAdd = ret ? ret : infoCanAdd( h, destination, setme_info );
     292    if( ret == TR_OK )
     293        ret = infoCanAdd( h, destination, setme_info );
    295294
    296295    return ret;
     
    305304{
    306305    int val;
    307     int err = 0;
    308306    tr_torrent_t * tor = NULL;
    309307
    310     if(( val = tr_torrentParse( h, destination, path, NULL, &err )))
     308    if(( val = tr_torrentParse( h, destination, path, NULL )))
    311309        *error = val;
    312     else if( err )
    313         *error = err;
    314310    else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
    315311        *error = TR_EOTHER;
     
    326322                     const char         * hashStr,
    327323                     const char         * destination,
    328                      tr_info_t          * setme_info,
    329                      int                * setme_canAdd )
     324                     tr_info_t          * setme_info )
    330325{
    331326    int ret;
     
    337332    ret = tr_metainfoParseHash( setme_info, h->tag, hashStr );
    338333
    339     if( setme_canAdd )
    340        *setme_canAdd = ret ? ret : infoCanAdd( h, destination, setme_info );
     334    if( ret == TR_OK )
     335        ret = infoCanAdd( h, destination, setme_info );
    341336
    342337    return ret;
     
    352347{
    353348    int val;
    354     int err = 0;
    355349    tr_torrent_t * tor = NULL;
    356350
    357     if(( val = tr_torrentParseHash( h, hashStr, destination, NULL, &err )))
     351    if(( val = tr_torrentParseHash( h, hashStr, destination, NULL )))
    358352        *error = val;
    359     else if( err )
    360         *error = err;
    361353    else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
    362354        *error = TR_EOTHER;
     
    374366                     size_t               size,
    375367                     const char         * destination,
    376                      tr_info_t          * setme_info,
    377                      int                * setme_canAdd )
     368                     tr_info_t          * setme_info )
    378369{
    379370    int ret;
     
    385376    ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE );
    386377
    387     if( setme_canAdd )
    388        *setme_canAdd = ret ? ret : infoCanAdd( h, destination, setme_info );
     378    if( ret == TR_OK )
     379        ret = infoCanAdd( h, destination, setme_info );
    389380
    390381    return ret;
     
    400391{
    401392    int val;
    402     int err = 0;
    403393    tr_torrent_t * tor = NULL;
    404394
    405     if(( val = tr_torrentParseData( h, data, size, destination, NULL, &err ) ))
     395    if(( val = tr_torrentParseData( h, data, size, destination, NULL )))
    406396        *error = val;
    407     else if( err )
    408         *error = err;
    409397    else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
    410398        *error = TR_EOTHER;
  • trunk/libtransmission/transmission.h

    r2207 r2210  
    275275 * Parses the specified metainfo file.
    276276 *
    277  * Returns TR_OK or TR_INVALID based on whether or not the
    278  * metainfo file is successfully parsed.
     277 * Returns TR_OK if it parsed and can be added to Transmission.
     278 * Returns TR_INVALID if it couldn't be parsed.
     279 * Returns TR_EDUPLICATE if it parsed but can't be added.
    279280 *
    280  * If parsing succeeded and "setme_info" is non-NULL,
    281  * it will be populated with the file's information.
     281 * "destination" can be NULL if you don't need to know whether
     282 * or not the torrent can be added.
    282283 *
    283  * If "setme_canAdd" is non-NULL, it will be set to TR_OK,
    284  * TR_EDUPLICATE, TR_ERROR_IO_DUP_DOWNLOAD, or TR_EINVALID.
    285  *
    286  * "destination" is used for the canAdd tests, so it can
    287  * be NULL if "setme_canAdd" is too.
     284 " "setme_info" can be NULL if you don't need the information.
     285 * If the metainfo can be parsed and setme_info is non-NULL,
     286 * it will be filled with the metadata's info.
    288287 */
    289288int tr_torrentParse( const tr_handle_t  * handle,
    290289                     const char         * metainfo_filename,
    291290                     const char         * destination,
    292                      tr_info_t          * setme_info,
    293                      int                * setme_canAdd );
     291                     tr_info_t          * setme_info );
    294292
    295293/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.