corrected a bug due to reading uint64_t with wrong format on some systems, which caused the hash cache to sometime fail

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4437 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-07-12 20:07:28 +00:00
parent e4f89892a3
commit fc05314af0

View File

@ -130,11 +130,22 @@ HashCache::HashCache(const std::string& path)
f.getline(buff,max_line_size,'\n') ; f.getline(buff,max_line_size,'\n') ;
std::string name(buff) ; std::string name(buff) ;
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%lld",&info.size) != 1) break ; f.getline(buff,max_line_size,'\n') ; //if(sscanf(buff,"%llu",&info.size) != 1) break ;
std::istringstream ss(buff) ;
info.size = 0 ;
ss >> info.size ;
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.time_stamp) != 1) break ; f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.time_stamp) != 1) break ;
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.modf_stamp) != 1) break ; f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,"%ld",&info.modf_stamp) != 1) break ;
f.getline(buff,max_line_size,'\n') ; info.hash = std::string(buff) ; f.getline(buff,max_line_size,'\n') ; info.hash = std::string(buff) ;
if(info.hash.length() != 40)
{
std::cerr << "Loaded hash is not a hash: " << info.hash << std::endl;
break ;
}
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << " (" << name << ", " << info.size << ", " << info.time_stamp << ", " << info.modf_stamp << ", " << info.hash << std::endl ; std::cerr << " (" << name << ", " << info.size << ", " << info.time_stamp << ", " << info.modf_stamp << ", " << info.hash << std::endl ;
++n ; ++n ;