mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 08:25:53 -04:00
fixed a bug in filterItems that caused searched files to generate an error in the console
This commit is contained in:
parent
d21a5e5875
commit
725abad777
2 changed files with 34 additions and 33 deletions
|
@ -1155,6 +1155,8 @@ int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::
|
||||||
if(flags & RS_FILE_HINTS_LOCAL)
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<EntryIndex> firesults;
|
||||||
|
std::list<void *> pointers;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
|
@ -1164,16 +1166,16 @@ int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::
|
||||||
{
|
{
|
||||||
void *p=NULL;
|
void *p=NULL;
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(*it,0,p);
|
convertEntryIndexToPointer<sizeof(void*)>(*it,0,p);
|
||||||
*it = (intptr_t)p ;
|
pointers.push_back(p) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterResults(firesults,results,flags,client_peer_id) ;
|
filterResults(pointers,results,flags,client_peer_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flags & RS_FILE_HINTS_REMOTE)
|
if(flags & RS_FILE_HINTS_REMOTE)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<void*> pointers ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
@ -1188,21 +1190,21 @@ int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::
|
||||||
{
|
{
|
||||||
void *p=NULL;
|
void *p=NULL;
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(*it,i+1,p);
|
convertEntryIndexToPointer<sizeof(void*)>(*it,i+1,p);
|
||||||
firesults.push_back((intptr_t)p) ;
|
|
||||||
|
pointers.push_back(p) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<EntryIndex>::const_iterator rit ( firesults.begin()); rit != firesults.end(); ++rit)
|
for(auto it(pointers.begin());it!=pointers.end();++it)
|
||||||
{
|
{
|
||||||
DirDetails dd;
|
DirDetails dd;
|
||||||
|
|
||||||
if(!RequestDirDetails ((void*)(intptr_t)*rit,dd,RS_FILE_HINTS_REMOTE))
|
if(!RequestDirDetails (*it,dd,RS_FILE_HINTS_REMOTE))
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
results.push_back(dd);
|
results.push_back(dd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !results.empty() ;
|
return !results.empty() ;
|
||||||
|
@ -1213,6 +1215,7 @@ int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::lis
|
||||||
if(flags & RS_FILE_HINTS_LOCAL)
|
if(flags & RS_FILE_HINTS_LOCAL)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<EntryIndex> firesults;
|
||||||
|
std::list<void*> pointers;
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
|
@ -1222,17 +1225,16 @@ int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::lis
|
||||||
{
|
{
|
||||||
void *p=NULL;
|
void *p=NULL;
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(*it,0,p);
|
convertEntryIndexToPointer<sizeof(void*)>(*it,0,p);
|
||||||
*it = (intptr_t)p ;
|
pointers.push_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filterResults(firesults,results,flags,client_peer_id) ;
|
filterResults(pointers,results,flags,client_peer_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flags & RS_FILE_HINTS_REMOTE)
|
if(flags & RS_FILE_HINTS_REMOTE)
|
||||||
{
|
{
|
||||||
std::list<EntryIndex> firesults;
|
std::list<void*> pointers ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mFLSMtx) ;
|
RS_STACK_MUTEX(mFLSMtx) ;
|
||||||
|
|
||||||
|
@ -1246,17 +1248,16 @@ int p3FileDatabase::SearchBoolExp(RsRegularExpression::Expression *exp, std::lis
|
||||||
{
|
{
|
||||||
void *p=NULL;
|
void *p=NULL;
|
||||||
convertEntryIndexToPointer<sizeof(void*)>(*it,i+1,p);
|
convertEntryIndexToPointer<sizeof(void*)>(*it,i+1,p);
|
||||||
firesults.push_back((intptr_t)p) ;
|
pointers.push_back(p) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<EntryIndex>::const_iterator rit ( firesults.begin()); rit != firesults.end(); ++rit)
|
for(auto it(pointers.begin());it!=pointers.end();++it)
|
||||||
{
|
{
|
||||||
DirDetails dd;
|
DirDetails dd;
|
||||||
|
|
||||||
if(!RequestDirDetails ((void*)(intptr_t)*rit,dd,RS_FILE_HINTS_REMOTE))
|
if(!RequestDirDetails (*it,dd,RS_FILE_HINTS_REMOTE))
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
results.push_back(dd);
|
results.push_back(dd);
|
||||||
|
@ -1312,7 +1313,7 @@ bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, F
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3FileDatabase::filterResults(const std::list<EntryIndex>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const
|
int p3FileDatabase::filterResults(const std::list<void*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const
|
||||||
{
|
{
|
||||||
results.clear();
|
results.clear();
|
||||||
|
|
||||||
|
@ -1320,17 +1321,17 @@ int p3FileDatabase::filterResults(const std::list<EntryIndex>& firesults,std::li
|
||||||
|
|
||||||
/* translate/filter results */
|
/* translate/filter results */
|
||||||
|
|
||||||
for(std::list<EntryIndex>::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit)
|
for(std::list<void*>::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit)
|
||||||
{
|
{
|
||||||
DirDetails cdetails ;
|
DirDetails cdetails ;
|
||||||
|
|
||||||
if(!RequestDirDetails ((void*)(intptr_t)*rit,cdetails,RS_FILE_HINTS_LOCAL))
|
if(!RequestDirDetails (*rit,cdetails,RS_FILE_HINTS_LOCAL))
|
||||||
{
|
{
|
||||||
P3FILELISTS_ERROR() << "(EE) Cannot get dir details for entry " << (void*)(intptr_t)*rit << std::endl;
|
P3FILELISTS_ERROR() << "(EE) Cannot get dir details for entry " << *rit << std::endl;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_P3FILELISTS
|
#ifdef DEBUG_P3FILELISTS
|
||||||
P3FILELISTS_DEBUG() << "Filtering candidate " << (void*)(intptr_t)(*rit) << ", flags=" << cdetails.flags << ", peer=" << peer_id ;
|
P3FILELISTS_DEBUG() << "Filtering candidate " << *rit << ", flags=" << cdetails.flags << ", peer=" << peer_id ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!peer_id.isNull())
|
if(!peer_id.isNull())
|
||||||
|
|
|
@ -159,7 +159,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int filterResults(const std::list<EntryIndex>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const;
|
int filterResults(const std::list<void*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const;
|
||||||
std::string makeRemoteFileName(const RsPeerId& pid) const;
|
std::string makeRemoteFileName(const RsPeerId& pid) const;
|
||||||
|
|
||||||
// Derived from p3Config
|
// Derived from p3Config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue