mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 08:37:36 -04:00
the cache is corrected and saved
This commit is contained in:
parent
683e3579aa
commit
3f8611f40f
3 changed files with 35 additions and 9 deletions
|
@ -133,12 +133,7 @@ void HashStorage::data_tick()
|
||||||
|
|
||||||
if(!mChanged) // otherwise it might prevent from saving the hash cache
|
if(!mChanged) // otherwise it might prevent from saving the hash cache
|
||||||
{
|
{
|
||||||
std::cerr << "Stopping hashing thread." << std::endl;
|
stopHashThread();
|
||||||
shutdown();
|
|
||||||
mRunning = false ;
|
|
||||||
mTotalSizeToHash = 0;
|
|
||||||
mTotalFilesToHash = 0;
|
|
||||||
std::cerr << "done." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
|
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
|
||||||
|
@ -261,6 +256,16 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
|
||||||
{
|
{
|
||||||
it->second.time_stamp = now ;
|
it->second.time_stamp = now ;
|
||||||
|
|
||||||
|
#ifdef WINDOWS_SYS
|
||||||
|
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.modf_stamp = (uint64_t)mod_time;
|
||||||
|
mChanged = true;
|
||||||
|
startHashThread();
|
||||||
|
}
|
||||||
|
#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 ;
|
||||||
|
@ -293,6 +298,13 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
|
||||||
mTotalSizeToHash += size ;
|
mTotalSizeToHash += size ;
|
||||||
++mTotalFilesToHash;
|
++mTotalFilesToHash;
|
||||||
|
|
||||||
|
startHashThread();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HashStorage::startHashThread()
|
||||||
|
{
|
||||||
if(!mRunning)
|
if(!mRunning)
|
||||||
{
|
{
|
||||||
mRunning = true ;
|
mRunning = true ;
|
||||||
|
@ -302,8 +314,19 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_
|
||||||
|
|
||||||
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()
|
void HashStorage::clean()
|
||||||
|
|
|
@ -97,6 +97,9 @@ private:
|
||||||
*/
|
*/
|
||||||
void clean() ;
|
void clean() ;
|
||||||
|
|
||||||
|
void startHashThread();
|
||||||
|
void stopHashThread();
|
||||||
|
|
||||||
// loading/saving the entire hash database to a file
|
// loading/saving the entire hash database to a file
|
||||||
|
|
||||||
void locked_save() ;
|
void locked_save() ;
|
||||||
|
|
|
@ -201,7 +201,7 @@ void RsThread::start(const std::string &threadName)
|
||||||
if(threadName.length() > 15)
|
if(threadName.length() > 15)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_THREADS
|
#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
|
#endif
|
||||||
RS_pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
|
RS_pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue