Changeset 8122
- Timestamp:
- Apr 2, 2009, 5:30:29 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/cli.c
r8108 r8122 356 356 tr_info info; 357 357 358 if( !tr_torrentParse( h,ctor, &info ) )358 if( !tr_torrentParse( ctor, &info ) ) 359 359 { 360 360 int i; … … 392 392 tr_info info; 393 393 394 if( !tr_torrentParse( h,ctor, &info ) )394 if( !tr_torrentParse( ctor, &info ) ) 395 395 { 396 396 dumpInfo( stdout, &info ); … … 402 402 } 403 403 404 tor = tr_torrentNew( h,ctor, &error );404 tor = tr_torrentNew( ctor, &error ); 405 405 tr_ctorFree( ctor ); 406 406 if( !tor ) -
trunk/daemon/daemon.c
r8108 r8122 191 191 int err = tr_ctorSetMetainfoFromFile( ctor, filename ); 192 192 if( !err ) 193 tr_torrentNew( session,ctor, &err );193 tr_torrentNew( ctor, &err ); 194 194 195 195 tr_ctorFree( ctor ); -
trunk/gtk/add-dialog.c
r7774 r8122 172 172 int new_file = 0; 173 173 tr_torrent * torrent; 174 tr_session * session = tr_core_session( data->core );175 174 176 175 if( filename … … 187 186 tr_ctorSetDeleteSource( data->ctor, FALSE ); 188 187 189 if( ( torrent = tr_torrentNew( session,data->ctor, &err ) ) )188 if( ( torrent = tr_torrentNew( data->ctor, &err ) ) ) 190 189 { 191 190 removeOldTorrent( data ); -
trunk/gtk/tr-core.c
r7976 r8122 928 928 { 929 929 tr_info inf; 930 int err = tr_torrentParse( session,ctor, &inf );930 int err = tr_torrentParse( ctor, &inf ); 931 931 932 932 switch( err ) -
trunk/gtk/tr-torrent.c
r7860 r8122 199 199 tr_ctorGetDeleteSource( ctor, &doTrash ); 200 200 tr_ctorSetDeleteSource( ctor, FALSE ); 201 tor = tr_torrentNew( session,ctor, errcode );201 tor = tr_torrentNew( ctor, errcode ); 202 202 203 203 if( tor && doTrash ) -
trunk/libtransmission/fdlimit.c
r7801 r8122 444 444 else if( o->syncAt <= time( NULL ) ) { 445 445 dbgmsg( "fsync()ing file '%s' in slot #%d", o->filename, i ); 446 fsync( o->fd );446 //fsync( o->fd ); 447 447 #ifdef HAVE_POSIX_FADVISE 448 448 /* TODO: test performance with and without this */ -
trunk/libtransmission/metainfo.c
r7657 r8122 441 441 /* filename of Transmission's copy */ 442 442 tr_free( inf->torrent ); 443 inf->torrent = getTorrentFilename( session, inf );443 inf->torrent = session ? getTorrentFilename( session, inf ) : NULL; 444 444 445 445 return NULL; -
trunk/libtransmission/rpcimpl.c
r8121 r8122 746 746 int err = 0; 747 747 const char * result = NULL; 748 tr_torrent * tor = tr_torrentNew( data->session,ctor, &err );748 tr_torrent * tor = tr_torrentNew( ctor, &err ); 749 749 750 750 tr_ctorFree( ctor ); -
trunk/libtransmission/session.c
r8118 r8122 1369 1369 char * path = tr_buildPath( dirname, d->d_name, NULL ); 1370 1370 tr_ctorSetMetainfoFromFile( ctor, path ); 1371 if(( tor = tr_torrentNew( session,ctor, NULL )))1371 if(( tor = tr_torrentNew( ctor, NULL ))) 1372 1372 { 1373 1373 tr_list_append( &list, tor ); … … 1620 1620 char * path = tr_buildPath( dirname, d->d_name, NULL ); 1621 1621 tr_ctorSetMetainfoFromFile( ctor, path ); 1622 if( !tr_torrentParse( session,ctor, &inf ) )1622 if( !tr_torrentParse( ctor, &inf ) ) 1623 1623 { 1624 1624 tr_list_append( &list, tr_strdup( inf.hashString ) ); -
trunk/libtransmission/torrent-ctor.c
r7658 r8122 292 292 } 293 293 294 tr_session* 295 tr_ctorGetSession( const tr_ctor * ctor ) 296 { 297 return (tr_session*) ctor->session; 298 } 299 294 300 /*** 295 301 **** … … 302 308 303 309 ctor->session = session; 304 tr_ctorSetPeerLimit( ctor, TR_FALLBACK, session->peerLimitPerTorrent );305 310 tr_ctorSetPaused( ctor, TR_FALLBACK, FALSE ); 306 tr_ctorSetDownloadDir( ctor, TR_FALLBACK, session->downloadDir ); 311 if( session != NULL ) { 312 tr_ctorSetPeerLimit( ctor, TR_FALLBACK, session->peerLimitPerTorrent ); 313 tr_ctorSetDownloadDir( ctor, TR_FALLBACK, session->downloadDir ); 314 } 307 315 tr_ctorSetSave( ctor, TRUE ); 308 316 return ctor; … … 317 325 tr_free( ctor ); 318 326 } 319 -
trunk/libtransmission/torrent.c
r8097 r8122 504 504 505 505 static void 506 torrentRealInit( tr_session * session, 507 tr_torrent * tor, 508 const tr_ctor * ctor ) 506 torrentRealInit( tr_torrent * tor, const tr_ctor * ctor ) 509 507 { 510 508 int doStart; … … 514 512 static int nextUniqueId = 1; 515 513 tr_info * info = &tor->info; 514 tr_session * session = tr_ctorGetSession( ctor ); 515 516 assert( session != NULL ); 516 517 517 518 tr_globalLock( session ); … … 648 649 649 650 int 650 tr_torrentParse( const tr_session * session, 651 const tr_ctor * ctor, 651 tr_torrentParse( const tr_ctor * ctor, 652 652 tr_info * setmeInfo ) 653 653 { … … 656 656 tr_info tmp; 657 657 const tr_benc * metainfo; 658 tr_session * session = tr_ctorGetSession( ctor ); 658 659 659 660 if( setmeInfo == NULL ) … … 670 671 err = TR_EINVALID; 671 672 672 if( !err && tr_torrentExists( session, setmeInfo->hash ) )673 if( !err && session && tr_torrentExists( session, setmeInfo->hash ) ) 673 674 err = TR_EDUPLICATE; 674 675 … … 680 681 681 682 tr_torrent * 682 tr_torrentNew( tr_session * session, 683 const tr_ctor * ctor, 683 tr_torrentNew( const tr_ctor * ctor, 684 684 int * setmeError ) 685 685 { … … 688 688 tr_torrent * tor = NULL; 689 689 690 err = tr_torrentParse( session, ctor, &tmpInfo ); 690 assert( ctor != NULL ); 691 assert( tr_isSession( tr_ctorGetSession( ctor ) ) ); 692 693 err = tr_torrentParse( ctor, &tmpInfo ); 691 694 if( !err ) 692 695 { 693 696 tor = tr_new0( tr_torrent, 1 ); 694 697 tor->info = tmpInfo; 695 torrentRealInit( session,tor, ctor );698 torrentRealInit( tor, ctor ); 696 699 } 697 700 else if( setmeError ) -
trunk/libtransmission/transmission.h
r8118 r8122 755 755 struct tr_benc; 756 756 757 tr_ctor* tr_ctorNew( const tr_session * session ); 757 /* it's okay to use NULL here if you're only parsing the torrent. 758 * @see tr_torrentParse() */ 759 tr_ctor* tr_ctorNew( const tr_session * session_or_NULL ); 758 760 759 761 void tr_ctorFree( tr_ctor * ctor ); … … 809 811 tr_bool * setmeDoDelete ); 810 812 813 tr_session* tr_ctorGetSession( const tr_ctor * ctor ); 814 811 815 /* returns NULL if tr_ctorSetMetainfoFromFile() wasn't used */ 812 816 const char* tr_ctorGetSourceFile( const tr_ctor * ctor ); … … 826 830 * metainfo is stored in setme_info and should be freed by the 827 831 * caller via tr_metainfoFree(). 828 */ 829 int tr_torrentParse( const tr_session * session, 830 const tr_ctor * ctor, 831 tr_info * setme_info_or_NULL ); 832 * 833 * If the constructor's session variable is NULL, 834 * info.torrent will be NULL and the duplicate check will not be performed. 835 */ 836 int tr_torrentParse( const tr_ctor * ctor, 837 tr_info * setme_info_or_NULL ); 832 838 833 839 /** @brief free a metainfo … … 840 846 TR_EINVALID if the torrent couldn't be parsed, or 841 847 TR_EDUPLICATE if there's already a matching torrent object. */ 842 tr_torrent * tr_torrentNew( tr_session * session, 843 const tr_ctor * ctor, 848 tr_torrent * tr_torrentNew( const tr_ctor * ctor, 844 849 int * setmeError ); 845 850 -
trunk/macosx/Controller.m
r8119 r8122 794 794 tr_ctor * ctor = tr_ctorNew(fLib); 795 795 tr_ctorSetMetainfoFromFile(ctor, [torrentPath UTF8String]); 796 int result = tr_torrentParse( fLib,ctor, &info);796 int result = tr_torrentParse(ctor, &info); 797 797 if (result != TR_OK) 798 798 { … … 2458 2458 tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); 2459 2459 2460 switch (tr_torrentParse( fLib,ctor, NULL))2460 switch (tr_torrentParse(ctor, NULL)) 2461 2461 { 2462 2462 case TR_OK: … … 2698 2698 tr_ctor * ctor = tr_ctorNew(fLib); 2699 2699 tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); 2700 switch (tr_torrentParse( fLib,ctor, NULL))2700 switch (tr_torrentParse(ctor, NULL)) 2701 2701 { 2702 2702 case TR_OK: … … 2762 2762 tr_ctor * ctor = tr_ctorNew(fLib); 2763 2763 tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); 2764 switch (tr_torrentParse( fLib,ctor, NULL))2764 switch (tr_torrentParse(ctor, NULL)) 2765 2765 { 2766 2766 case TR_OK: -
trunk/macosx/DragOverlayWindow.m
r7659 r8122 89 89 tr_ctorSetMetainfoFromFile(ctor, [file UTF8String]); 90 90 tr_info info; 91 if (tr_torrentParse( fLib,ctor, &info) == TR_OK)91 if (tr_torrentParse(ctor, &info) == TR_OK) 92 92 { 93 93 count++; -
trunk/macosx/Torrent.m
r8098 r8122 1624 1624 { 1625 1625 tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]); 1626 if (tr_torrentParse( lib,ctor, &info) == TR_OK)1626 if (tr_torrentParse(ctor, &info) == TR_OK) 1627 1627 { 1628 1628 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] … … 1630 1630 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1631 1631 1632 fHandle = tr_torrentNew( lib,ctor, NULL);1632 fHandle = tr_torrentNew(ctor, NULL); 1633 1633 } 1634 1634 tr_metainfoFree(&info); … … 1637 1637 { 1638 1638 tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); 1639 if (tr_torrentParse( lib,ctor, &info) == TR_OK)1639 if (tr_torrentParse(ctor, &info) == TR_OK) 1640 1640 { 1641 1641 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] … … 1643 1643 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1644 1644 1645 fHandle = tr_torrentNew( lib,ctor, NULL);1645 fHandle = tr_torrentNew(ctor, NULL); 1646 1646 } 1647 1647 tr_metainfoFree(&info);
Note: See TracChangeset
for help on using the changeset viewer.