Changeset 10972


Ignore:
Timestamp:
Jul 7, 2010, 11:37:03 PM (12 years ago)
Author:
charles
Message:

(trunk libt) #3402 "cache-size parameter not retained in settings.json after a restart" -- fixed

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r10945 r10972  
    315315    tr_bencDictReserve( d, 60 );
    316316    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED,        tr_blocklistIsEnabled( s ) );
    317     tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB,        tr_cacheGetLimit( s->cache ) );
     317    tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB,        tr_sessionGetCacheLimit_MB( s ) );
    318318    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED,              s->isDHTEnabled );
    319319    tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED,              s->isLPDEnabled );
     
    18941894
    18951895void
    1896 tr_sessionSetCacheLimit_B( tr_session * session, uint64_t max_bytes )
    1897 {
    1898     assert( tr_isSession( session ) );
    1899 
    1900     tr_cacheSetLimit( session->cache, max_bytes );
    1901 }
    1902 void
    1903 tr_sessionSetCacheLimit_MB( tr_session * session, int MB )
    1904 {
    1905     tr_sessionSetCacheLimit_B( session, toMemBytes( MB ) );
    1906 }
    1907 
    1908 uint64_t
    1909 tr_sessionGetCacheLimit_B( const tr_session * session )
    1910 {
    1911     assert( tr_isSession( session ) );
    1912 
    1913     return tr_cacheGetLimit( session->cache );
    1914 }
     1896tr_sessionSetCacheLimit_MB( tr_session * session, int max_bytes )
     1897{
     1898    assert( tr_isSession( session ) );
     1899
     1900    tr_cacheSetLimit( session->cache, toMemBytes( max_bytes ) );
     1901}
     1902
    19151903int
    19161904tr_sessionGetCacheLimit_MB( const tr_session * session )
    19171905{
    1918     return toMemMB( tr_sessionGetCacheLimit_B( session ) );
    1919 }
    1920 
     1906    assert( tr_isSession( session ) );
     1907
     1908    return toMemMB( tr_cacheGetLimit( session->cache ) );
     1909}
    19211910
    19221911/***
  • trunk/libtransmission/session.h

    r10945 r10972  
    274274
    275275static inline uint64_t toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
    276 static inline int      toMemMB    ( uint64_t B )      { return B / tr_mem_K; }
     276static inline int      toMemMB    ( uint64_t B )      { return B / ( tr_mem_K * tr_mem_K ); }
    277277
    278278/**
    279279**/
    280 
    281 void     tr_sessionSetCacheLimit_B ( tr_session * session, uint64_t B );
    282 uint64_t tr_sessionGetCacheLimit_B ( const tr_session * session );
    283280
    284281int  tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
Note: See TracChangeset for help on using the changeset viewer.