avoid corrupting file cache on 64bits architectures that store time_t as 32 bits

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6619 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-08-26 17:44:38 +00:00
parent 299678b9c8
commit a98642dab5
2 changed files with 4 additions and 4 deletions

View File

@ -199,7 +199,7 @@ bool HashCache::find(const std::string& full_path,uint64_t size,time_t time_stam
time_t now = time(NULL) ; time_t now = time(NULL) ;
std::map<std::string,HashCacheInfo>::iterator it(_files.find(full_path)) ; std::map<std::string,HashCacheInfo>::iterator it(_files.find(full_path)) ;
if(it != _files.end() && time_stamp == it->second.modf_stamp && size == it->second.size) if(it != _files.end() && (uint64_t)time_stamp == it->second.modf_stamp && size == it->second.size)
{ {
hash = it->second.hash ; hash = it->second.hash ;
it->second.time_stamp = now ; it->second.time_stamp = now ;
@ -244,7 +244,7 @@ void HashCache::clean()
#endif #endif
for(std::map<std::string,HashCacheInfo>::iterator it(_files.begin());it!=_files.end();) for(std::map<std::string,HashCacheInfo>::iterator it(_files.begin());it!=_files.end();)
if(it->second.time_stamp + duration < now) if(it->second.time_stamp + duration < (uint64_t)now)
{ {
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << " Entry too old: " << it->first << ", ts=" << it->second.time_stamp << std::endl ; std::cerr << " Entry too old: " << it->first << ", ts=" << it->second.time_stamp << std::endl ;

View File

@ -84,8 +84,8 @@ class HashCache
typedef struct typedef struct
{ {
uint64_t size ; uint64_t size ;
time_t time_stamp ; uint64_t time_stamp ;
time_t modf_stamp ; uint64_t modf_stamp ;
std::string hash ; std::string hash ;
} HashCacheInfo ; } HashCacheInfo ;