mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 12:24:24 -04:00
use partial saves only when really hashing something
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3733 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d593be9cbb
commit
f2609fa3ce
1 changed files with 7 additions and 3 deletions
|
@ -822,6 +822,7 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||||
|
|
||||||
uint32_t cnt=0 ;
|
uint32_t cnt=0 ;
|
||||||
uint64_t size=0 ;
|
uint64_t size=0 ;
|
||||||
|
uint64_t hashed_size=0 ;
|
||||||
uint64_t last_save_size=0 ;
|
uint64_t last_save_size=0 ;
|
||||||
|
|
||||||
/* update files */
|
/* update files */
|
||||||
|
@ -852,6 +853,8 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||||
|
|
||||||
fi.updateFileEntry(to_hash[i].dirpath,fe,stamp);
|
fi.updateFileEntry(to_hash[i].dirpath,fe,stamp);
|
||||||
|
|
||||||
|
hashed_size += to_hash[i].fentries[j].size ;
|
||||||
|
|
||||||
// Update the hash cache
|
// Update the hash cache
|
||||||
if(useHashCache)
|
if(useHashCache)
|
||||||
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
||||||
|
@ -871,8 +874,9 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Save the hashing result every 60 seconds, so has to save what is already hashed.
|
// Save the hashing result every 60 seconds, so has to save what is already hashed.
|
||||||
std::cerr << "size - last_save_size = " << size - last_save_size << ", max=" << MAX_SIZE_WITHOUT_SAVING << std::endl ;
|
std::cerr << "size - last_save_size = " << hashed_size - last_save_size << ", max=" << MAX_SIZE_WITHOUT_SAVING << std::endl ;
|
||||||
if(size > last_save_size + MAX_SIZE_WITHOUT_SAVING)
|
|
||||||
|
if(hashed_size > last_save_size + MAX_SIZE_WITHOUT_SAVING)
|
||||||
{
|
{
|
||||||
cb->notifyHashingInfo(NOTIFY_HASHTYPE_SAVE_FILE_INDEX, "") ;
|
cb->notifyHashingInfo(NOTIFY_HASHTYPE_SAVE_FILE_INDEX, "") ;
|
||||||
#ifdef WINDOWS_SYS
|
#ifdef WINDOWS_SYS
|
||||||
|
@ -882,7 +886,7 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||||
#endif
|
#endif
|
||||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||||
FileIndexMonitor::locked_saveFileIndexes() ;
|
FileIndexMonitor::locked_saveFileIndexes() ;
|
||||||
last_save_size = size ;
|
last_save_size = hashed_size ;
|
||||||
|
|
||||||
if(useHashCache)
|
if(useHashCache)
|
||||||
hashCache.save() ;
|
hashCache.save() ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue