mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
added small hack against re-hashing due to stat64 depending on local time on windows
This commit is contained in:
parent
9ce4b13e50
commit
71a5bffed8
@ -191,9 +191,29 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t
|
|||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(full_path) ;
|
std::map<std::string,HashStorageInfo>::iterator it = mFiles.find(full_path) ;
|
||||||
|
|
||||||
if(it != mFiles.end() && (uint64_t)mod_time == it->second.modf_stamp && size == it->second.size)
|
// On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change.
|
||||||
|
//
|
||||||
|
// See:
|
||||||
|
// https://support.microsoft.com/en-us/kb/190315
|
||||||
|
//
|
||||||
|
if(it != mFiles.end()
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
&& ( (uint64_t)mod_time == it->second.modf_stamp || (uint64_t)mod_time+3600 == it->second.modf_stamp ||(uint64_t)mod_time == it->second.modf_stamp+3600)
|
||||||
|
#else
|
||||||
|
&& (uint64_t)mod_time == it->second.modf_stamp
|
||||||
|
#endif
|
||||||
|
&& size == it->second.size)
|
||||||
{
|
{
|
||||||
it->second.time_stamp = now ;
|
it->second.time_stamp = now ;
|
||||||
|
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
if(it->second.time_stamp != (uint64_t)mod_time)
|
||||||
|
{
|
||||||
|
std::cerr << "(WW) detected a 1 hour shift in file modification time. This normally happens to many files at once, when daylight saving time shifts (file=\"" << full_path << "\")." << std::endl;
|
||||||
|
it->second.time_stamp = (uint64_t)mod_time;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
known_hash = it->second.hash;
|
known_hash = it->second.hash;
|
||||||
#ifdef HASHSTORAGE_DEBUG
|
#ifdef HASHSTORAGE_DEBUG
|
||||||
std::cerr << "Found in cache." << std::endl ;
|
std::cerr << "Found in cache." << std::endl ;
|
||||||
|
Loading…
Reference in New Issue
Block a user