Changeset 8477
- Timestamp:
- May 22, 2009, 4:03:12 AM (14 years ago)
- Location:
- branches/1.6x/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6x/libtransmission/metainfo.c
r8122 r8477 75 75 } 76 76 77 /* this is for really old versions of T and will probably be removed someday */ 77 78 void 78 79 tr_metainfoMigrate( tr_session * session, -
branches/1.6x/libtransmission/session.c
r8457 r8477 51 51 tr_deepLog( __FILE__, __LINE__, NULL, __VA_ARGS__ ); \ 52 52 } while( 0 ) 53 54 struct tr_metainfo_lookup 55 { 56 char hashString[2 * SHA_DIGEST_LENGTH + 1]; 57 char * filename; 58 }; 53 59 54 60 static tr_port … … 446 452 } 447 453 448 static void metainfoLookupRescan( tr_session * );449 454 static void tr_sessionInitImpl( void * ); 450 455 static void onAltTimer( int, short, void* ); … … 757 762 tr_statsInit( session ); 758 763 session->web = tr_webInit( session ); 759 metainfoLookupRescan( session );760 764 session->isWaiting = FALSE; 761 765 dbgmsg( "returning session %p; session->tracker is %p", session, session->tracker ); … … 1686 1690 1687 1691 return strcmp( a, b->hashString ); 1688 }1689 1690 const char*1691 tr_sessionFindTorrentFile( const tr_session * session,1692 const char * hashStr )1693 {1694 struct tr_metainfo_lookup * l = bsearch( hashStr,1695 session->metainfoLookup,1696 session->metainfoLookupCount,1697 sizeof( struct tr_metainfo_lookup ),1698 compareHashStringToLookupEntry );1699 1700 return l ? l->filename : NULL;1701 1692 } 1702 1693 … … 1759 1750 } 1760 1751 1752 static struct tr_metainfo_lookup * 1753 metainfoLookup( const tr_session * session, const char * hashString ) 1754 { 1755 /* because only the mac client uses metainfoLookup, and because building 1756 * the lookup is expensive, we hold off on building it until the client 1757 * actually asks to look up a hash... */ 1758 if( !session->metainfoLookupCount ) 1759 metainfoLookupRescan( (tr_session*)session ); 1760 1761 return bsearch( hashString, 1762 session->metainfoLookup, 1763 session->metainfoLookupCount, 1764 sizeof( struct tr_metainfo_lookup ), 1765 compareHashStringToLookupEntry ); 1766 } 1767 1768 const char* 1769 tr_sessionFindTorrentFile( const tr_session * session, 1770 const char * hashString ) 1771 { 1772 const struct tr_metainfo_lookup * l = metainfoLookup( session, hashString ); 1773 1774 return l ? l->filename : NULL; 1775 } 1776 1761 1777 void 1762 1778 tr_sessionSetTorrentFile( tr_session * session, … … 1764 1780 const char * filename ) 1765 1781 { 1766 struct tr_metainfo_lookup * l = bsearch( hashString, 1767 session->metainfoLookup, 1768 session->metainfoLookupCount, 1769 sizeof( struct tr_metainfo_lookup ), 1770 compareHashStringToLookupEntry ); 1771 1782 struct tr_metainfo_lookup * l; 1783 1784 /* since we walk session->configDir/torrents/ to build the lookup table, 1785 * and tr_sessionSetTorrentFile() is just to tell us there's a new file 1786 * in that same directory, we don't need to do anything here if the 1787 * lookup table hasn't been built yet */ 1788 if( session->metainfoLookup == NULL ) 1789 return; 1790 1791 l = metainfoLookup( session, hashString ); 1772 1792 if( l ) 1773 1793 { … … 1943 1963 return tr_rpcGetBindAddress( session->rpcServer ); 1944 1964 } 1945 1946 /***1947 ****1948 ***/1949 1950 tr_bool1951 tr_sessionIsProxyEnabled( const tr_session * session )1952 {1953 assert( tr_isSession( session ) );1954 1955 return session->isProxyEnabled;1956 }1957 1958 void1959 1965 tr_sessionSetProxyEnabled( tr_session * session, 1960 1966 tr_bool isEnabled ) -
branches/1.6x/libtransmission/session.h
r8243 r8477 48 48 const uint8_t* tr_getPeerId( void ); 49 49 50 struct tr_metainfo_lookup51 {52 char hashString[2 * SHA_DIGEST_LENGTH + 1];53 char * filename;54 };55 56 50 struct tr_address; 57 51 struct tr_bandwidth; 52 struct tr_metainfo_lookup; 58 53 59 54 struct tr_session
Note: See TracChangeset
for help on using the changeset viewer.