Merge pull request #1510 from zapek/windows_hash_warning_fix

fixed wrong file hash daylight saving time warnings on windows
This commit is contained in:
csoler 2019-04-10 20:34:40 +02:00 committed by GitHub
commit 565afbd834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 11 deletions

View File

@ -133,12 +133,7 @@ void HashStorage::data_tick()
if(!mChanged) // otherwise it might prevent from saving the hash cache
{
std::cerr << "Stopping hashing thread." << std::endl;
shutdown();
mRunning = false ;
mTotalSizeToHash = 0;
mTotalFilesToHash = 0;
std::cerr << "done." << std::endl;
stopHashThread();
}
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
@ -262,10 +257,12 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
it->second.time_stamp = now ;
#ifdef WINDOWS_SYS
if(it->second.time_stamp != (uint64_t)mod_time)
if(it->second.modf_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;
it->second.modf_stamp = (uint64_t)mod_time;
mChanged = true;
startHashThread();
}
#endif
@ -301,6 +298,13 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
mTotalSizeToHash += size ;
++mTotalFilesToHash;
startHashThread();
return false;
}
void HashStorage::startHashThread()
{
if(!mRunning)
{
mRunning = true ;
@ -308,10 +312,21 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
mHashCounter = 0;
mTotalHashedSize = 0;
start("fs hash cache") ;
start("fs hash cache") ;
}
}
return false;
void HashStorage::stopHashThread()
{
if (mRunning)
{
std::cerr << "Stopping hashing thread." << std::endl;
shutdown();
mRunning = false ;
mTotalSizeToHash = 0;
mTotalFilesToHash = 0;
std::cerr << "done." << std::endl;
}
}
void HashStorage::clean()

View File

@ -97,6 +97,9 @@ private:
*/
void clean() ;
void startHashThread();
void stopHashThread();
// loading/saving the entire hash database to a file
void locked_save() ;

View File

@ -201,7 +201,7 @@ void RsThread::start(const std::string &threadName)
if(threadName.length() > 15)
{
#ifdef DEBUG_THREADS
THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl;
THREAD_DEBUG << "RsThread::start called with to long name '" << threadName << "' truncating..." << std::endl;
#endif
RS_pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
} else {