mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
enabled cache fill when on and empty. Cleaned the tooltips
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3730 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
630156a5e8
commit
80492cfd48
@ -509,6 +509,12 @@ void FileIndexMonitor::updateCycle()
|
||||
|
||||
std::vector<DirContentToHash> to_hash ;
|
||||
|
||||
bool cache_is_new ;
|
||||
{
|
||||
RsStackMutex mtx(fiMutex) ;
|
||||
cache_is_new = useHashCache && hashCache.empty() ;
|
||||
}
|
||||
|
||||
while(moretodo)
|
||||
{
|
||||
/* sleep a bit for each loop */
|
||||
@ -703,6 +709,9 @@ void FileIndexMonitor::updateCycle()
|
||||
std::cerr << "File Hasn't Changed:" << fname << std::endl;
|
||||
#endif
|
||||
fi.updateFileEntry(olddir->path, fe, stamp);
|
||||
|
||||
if(cache_is_new)
|
||||
hashCache.insert(realpath+"/"+fe.name,fe.size,fe.modtime,fe.hash) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -822,17 +831,17 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||
// This is a very basic progress notification. To be more complete and user friendly, one would
|
||||
// rather send a completion ratio based on the size of files vs/ total size.
|
||||
//
|
||||
FileEntry fe(to_hash[i].fentries[j]) ; // copied, because hashFile updates the hash member
|
||||
std::ostringstream tmpout;
|
||||
tmpout << cnt+1 << "/" << n_files << " (" << friendlyUnit(size) << " - " << int(size/double(total_size)*100.0) << "%) : " << to_hash[i].fentries[j].name ;
|
||||
tmpout << cnt+1 << "/" << n_files << " (" << friendlyUnit(size) << " - " << int(size/double(total_size)*100.0) << "%) : " << fe.name ;
|
||||
|
||||
cb->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout.str()) ;
|
||||
|
||||
FileEntry fe(to_hash[i].fentries[j]) ; // copied, because hashFile updates the hash member
|
||||
std::string real_path(to_hash[i].realpath + "/" + to_hash[i].fentries[j].name) ;
|
||||
std::string real_path(to_hash[i].realpath + "/" + fe.name) ;
|
||||
|
||||
// 1st look into the hash cache if this file already exists.
|
||||
//
|
||||
if(useHashCache && hashCache.find(real_path,to_hash[i].fentries[j].size,to_hash[i].fentries[j].modtime,fe.hash))
|
||||
if(useHashCache && hashCache.find(real_path,fe.size,fe.modtime,fe.hash))
|
||||
fi.updateFileEntry(to_hash[i].dirpath,fe,stamp);
|
||||
else if(RsDirUtil::hashFile(real_path, fe.hash)) // not found, then hash it.
|
||||
{
|
||||
@ -845,10 +854,10 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||
|
||||
// Update the hash cache
|
||||
if(useHashCache)
|
||||
hashCache.insert(real_path,to_hash[i].fentries[j].size,to_hash[i].fentries[j].modtime,fe.hash) ;
|
||||
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
||||
}
|
||||
else
|
||||
std::cerr << "Failed to Hash File " << to_hash[i].fentries[j].name << std::endl;
|
||||
std::cerr << "Failed to Hash File " << fe.name << std::endl;
|
||||
|
||||
size += to_hash[i].fentries[j].size ;
|
||||
|
||||
|
@ -92,6 +92,7 @@ class HashCache
|
||||
void setRememberHashFilesDuration(uint32_t days) { _max_cache_duration_days = days ; }
|
||||
uint32_t rememberHashFilesDuration() const { return _max_cache_duration_days ; }
|
||||
void clear() { _files.clear(); }
|
||||
bool empty() const { return _files.empty() ; }
|
||||
private:
|
||||
uint32_t _max_cache_duration_days ; // maximum duration of un-requested cache entries
|
||||
std::map<std::string, HashCacheInfo> _files ;
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>483</width>
|
||||
<width>485</width>
|
||||
<height>439</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -637,14 +637,10 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberHashesCB">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remember file hashes even if not shared. </p>
|
||||
<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This might be useful if you're sharing an </p>
|
||||
<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">external HD, to avoid re-hashing files when </p>
|
||||
<p align="justify" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">you plug it in.</p></body></html></string>
|
||||
<string>Remember file hashes even if not shared.
|
||||
This might be useful if you're sharing an
|
||||
external HD, to avoid re-hashing files when
|
||||
you plug it in.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remember hashed files for </string>
|
||||
@ -670,19 +666,6 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cleanHashCachePB">
|
||||
<property name="toolTip">
|
||||
|
Loading…
Reference in New Issue
Block a user