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

This commit is contained in:
Charles Kerr 2010-07-07 23:37:03 +00:00
parent b5e93da8f4
commit c993c1703a
2 changed files with 7 additions and 21 deletions

View File

@ -314,7 +314,7 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_bencDictReserve( d, 60 );
tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, tr_blocklistIsEnabled( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, tr_cacheGetLimit( s->cache ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_MAX_CACHE_SIZE_MB, tr_sessionGetCacheLimit_MB( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, s->isDHTEnabled );
tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, s->isLPDEnabled );
tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR, s->downloadDir );
@ -1893,31 +1893,20 @@ tr_sessionAllowsLPD( const tr_session * session )
***/
void
tr_sessionSetCacheLimit_B( tr_session * session, uint64_t max_bytes )
tr_sessionSetCacheLimit_MB( tr_session * session, int max_bytes )
{
assert( tr_isSession( session ) );
tr_cacheSetLimit( session->cache, max_bytes );
}
void
tr_sessionSetCacheLimit_MB( tr_session * session, int MB )
{
tr_sessionSetCacheLimit_B( session, toMemBytes( MB ) );
tr_cacheSetLimit( session->cache, toMemBytes( max_bytes ) );
}
uint64_t
tr_sessionGetCacheLimit_B( const tr_session * session )
{
assert( tr_isSession( session ) );
return tr_cacheGetLimit( session->cache );
}
int
tr_sessionGetCacheLimit_MB( const tr_session * session )
{
return toMemMB( tr_sessionGetCacheLimit_B( session ) );
}
assert( tr_isSession( session ) );
return toMemMB( tr_cacheGetLimit( session->cache ) );
}
/***
****

View File

@ -273,14 +273,11 @@ static inline unsigned int toSpeedBytes ( unsigned int KBps ) { return KBps * tr
static inline double toSpeedKBps ( unsigned int Bps ) { return Bps / (double)tr_speed_K; }
static inline uint64_t toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
static inline int toMemMB ( uint64_t B ) { return B / tr_mem_K; }
static inline int toMemMB ( uint64_t B ) { return B / ( tr_mem_K * tr_mem_K ); }
/**
**/
void tr_sessionSetCacheLimit_B ( tr_session * session, uint64_t B );
uint64_t tr_sessionGetCacheLimit_B ( const tr_session * session );
int tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
int tr_sessionGetAltSpeed_Bps ( const tr_session *, tr_direction );
int tr_sessionGetRawSpeed_Bps ( const tr_session *, tr_direction );