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:
csoler 2010-10-31 21:35:15 +00:00
parent 630156a5e8
commit 80492cfd48
3 changed files with 21 additions and 28 deletions

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Remember file hashes even if not shared. &lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This might be useful if you're sharing an &lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;external HD, to avoid re-hashing files when &lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;you plug it in.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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">