mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added methods to get files from hash(hash) in directory_storage and ftServer
This commit is contained in:
parent
2d72b88130
commit
0387a28e78
9 changed files with 122 additions and 44 deletions
|
@ -661,18 +661,9 @@ DirectoryStorage::EntryIndex InternalFileHierarchyStorage::getSubDirIndex(Direct
|
|||
return static_cast<DirEntry*>(mNodes[parent_index])->subdirs[dir_tab_index];
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::searchHash(const RsFileHash& hash,std::list<DirectoryStorage::EntryIndex>& results)
|
||||
bool InternalFileHierarchyStorage::searchHash(const RsFileHash& hash,DirectoryStorage::EntryIndex& result)
|
||||
{
|
||||
DirectoryStorage::EntryIndex indx ;
|
||||
|
||||
if(getIndexFromFileHash(hash,indx))
|
||||
{
|
||||
results.clear();
|
||||
results.push_back(indx) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return getIndexFromFileHash(hash,result);
|
||||
}
|
||||
|
||||
class DirectoryStorageExprFileEntry: public RsRegularExpression::ExpFileEntry
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
|
||||
// search. SearchHash is logarithmic. The other two are linear.
|
||||
|
||||
bool searchHash(const RsFileHash& hash,std::list<DirectoryStorage::EntryIndex>& results);
|
||||
bool searchHash(const RsFileHash& hash, DirectoryStorage::EntryIndex &result);
|
||||
int searchBoolExp(RsRegularExpression::Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const ;
|
||||
int searchTerms(const std::list<std::string>& terms, std::list<DirectoryStorage::EntryIndex> &results) const ; // does a logical OR between items of the list of terms
|
||||
|
||||
|
|
|
@ -168,10 +168,11 @@ bool DirectoryStorage::updateHash(const EntryIndex& index,const RsFileHash& hash
|
|||
return mFileHierarchy->updateHash(index,hash);
|
||||
}
|
||||
|
||||
int DirectoryStorage::searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const
|
||||
int DirectoryStorage::searchHash(const RsFileHash& hash, const RsFileHash& real_hash, EntryIndex& result) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchHash(hash,results);
|
||||
#warning code needed here
|
||||
return mFileHierarchy->searchHash(hash,result);
|
||||
}
|
||||
|
||||
void DirectoryStorage::load(const std::string& local_file_name)
|
||||
|
|
|
@ -53,7 +53,7 @@ class DirectoryStorage
|
|||
|
||||
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchHash(const RsFileHash& hash, const RsFileHash &real_hash, EntryIndex &results) const ;
|
||||
|
||||
// gets/sets the various time stamps:
|
||||
//
|
||||
|
|
|
@ -979,16 +979,20 @@ bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, F
|
|||
|
||||
if(hintflags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
std::list<EntryIndex> res;
|
||||
mLocalSharedDirs->searchHash(hash,res) ;
|
||||
RsFileHash real_hash ;
|
||||
EntryIndex indx;
|
||||
|
||||
if(res.empty())
|
||||
if(!mLocalSharedDirs->searchHash(hash,real_hash,indx))
|
||||
return false;
|
||||
|
||||
EntryIndex indx = *res.begin() ; // no need to report duplicates
|
||||
|
||||
mLocalSharedDirs->getFileInfo(indx,info) ;
|
||||
|
||||
if(!real_hash.isNull())
|
||||
{
|
||||
info.hash = real_hash ;
|
||||
info.transfer_info_flags |= RS_FILE_REQ_ENCRYPTED ;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue