mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 03:49:29 -04:00
fixed search on remote files
This commit is contained in:
parent
068955d419
commit
93e70ca30b
1 changed files with 100 additions and 20 deletions
|
@ -860,6 +860,8 @@ uint32_t p3FileDatabase::watchPeriod()
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id)
|
int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id)
|
||||||
|
{
|
||||||
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<EntryIndex> firesults;
|
||||||
{
|
{
|
||||||
|
@ -875,9 +877,49 @@ int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterResults(firesults,results,flags,client_peer_id) ;
|
filterResults(firesults,results,flags,client_peer_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(flags & RS_FILE_HINTS_REMOTE)
|
||||||
|
{
|
||||||
|
std::list<EntryIndex> firesults;
|
||||||
|
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||||
|
if(mRemoteDirectories[i] != NULL)
|
||||||
|
{
|
||||||
|
std::list<EntryIndex> local_results;
|
||||||
|
mRemoteDirectories[i]->searchTerms(keywords,local_results) ;
|
||||||
|
|
||||||
|
for(std::list<EntryIndex>::iterator it(local_results.begin());it!=local_results.end();++it)
|
||||||
|
{
|
||||||
|
void *p=NULL;
|
||||||
|
convertEntryIndexToPointer(*it,i+1,p);
|
||||||
|
firesults.push_back((intptr_t)p) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(std::list<EntryIndex>::const_iterator rit ( firesults.begin()); rit != firesults.end(); ++rit)
|
||||||
|
{
|
||||||
|
DirDetails dd;
|
||||||
|
|
||||||
|
if(!RequestDirDetails ((void*)(intptr_t)*rit,dd,RS_FILE_HINTS_REMOTE))
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
results.push_back(dd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return !results.empty() ;
|
||||||
|
}
|
||||||
|
|
||||||
int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id) const
|
int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id) const
|
||||||
|
{
|
||||||
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<EntryIndex> firesults;
|
||||||
{
|
{
|
||||||
|
@ -893,7 +935,45 @@ int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::lis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterResults(firesults,results,flags,client_peer_id) ;
|
filterResults(firesults,results,flags,client_peer_id) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flags & RS_FILE_HINTS_REMOTE)
|
||||||
|
{
|
||||||
|
std::list<EntryIndex> firesults;
|
||||||
|
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||||
|
if(mRemoteDirectories[i] != NULL)
|
||||||
|
{
|
||||||
|
std::list<EntryIndex> local_results;
|
||||||
|
mRemoteDirectories[i]->searchBoolExp(exp,local_results) ;
|
||||||
|
|
||||||
|
for(std::list<EntryIndex>::iterator it(local_results.begin());it!=local_results.end();++it)
|
||||||
|
{
|
||||||
|
void *p=NULL;
|
||||||
|
convertEntryIndexToPointer(*it,i+1,p);
|
||||||
|
firesults.push_back((intptr_t)p) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(std::list<EntryIndex>::const_iterator rit ( firesults.begin()); rit != firesults.end(); ++rit)
|
||||||
|
{
|
||||||
|
DirDetails dd;
|
||||||
|
|
||||||
|
if(!RequestDirDetails ((void*)(intptr_t)*rit,dd,RS_FILE_HINTS_REMOTE))
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
results.push_back(dd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !results.empty() ;
|
||||||
|
|
||||||
}
|
}
|
||||||
bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue