diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 4853873c5..2d92ceb7b 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -333,7 +333,7 @@ int FileIndexMonitor::filterResults(std::list& firesults,std::list& parent_groups) const { std::list results; bool ok = false; @@ -353,16 +353,13 @@ bool FileIndexMonitor::findLocalFile(std::string hash,FileSearchFlags hint_flags FileEntry *fe = results.front(); DirEntry *de = fe->parent; /* all files must have a valid parent! */ - std::list parent_groups ; - FileStorageFlags share_flags ; - - locked_findShareFlagsAndParentGroups(fe,share_flags,parent_groups) ; + locked_findShareFlagsAndParentGroups(fe,storage_flags,parent_groups) ; // turn share flags into hint flags - FileSearchFlags shflh = rsPeers->computePeerPermissionFlags(peer_id,share_flags,parent_groups) ; + FileSearchFlags shflh = peer_id.empty()?(RS_FILE_HINTS_BROWSABLE|RS_FILE_HINTS_NETWORK_WIDE):rsPeers->computePeerPermissionFlags(peer_id,storage_flags,parent_groups) ; #ifdef FIM_DEBUG - std::cerr << "FileIndexMonitor::findLocalFile: Filtering candidate " << fe->name << ", flags=" << share_flags << ", hint_flags=" << hint_flags << ", peer_id = " << peer_id << std::endl ; + std::cerr << "FileIndexMonitor::findLocalFile: Filtering candidate " << fe->name << ", flags=" << storage_flags << ", hint_flags=" << hint_flags << ", peer_id = " << peer_id << std::endl ; #endif if(peer_id.empty() || (shflh & hint_flags)) diff --git a/libretroshare/src/dbase/fimonitor.h b/libretroshare/src/dbase/fimonitor.h index 5011eddac..cfcd99be7 100644 --- a/libretroshare/src/dbase/fimonitor.h +++ b/libretroshare/src/dbase/fimonitor.h @@ -111,7 +111,7 @@ class FileIndexMonitor: public CacheSource, public RsThread virtual ~FileIndexMonitor(); /* external interface for filetransfer */ - bool findLocalFile(std::string hash,FileSearchFlags flags,const std::string& peer_id, std::string &fullpath, uint64_t &size) const; + bool findLocalFile(std::string hash,FileSearchFlags flags,const std::string& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list& parent_groups) const; int SearchKeywords(std::list keywords, std::list &results,FileSearchFlags flags,const std::string& peer_id) ; int SearchBoolExp(Expression *exp, std::list &results,FileSearchFlags flags,const std::string& peer_id) const ; diff --git a/libretroshare/src/ft/ftdbase.cc b/libretroshare/src/ft/ftdbase.cc index 506f7e582..091ff80cf 100644 --- a/libretroshare/src/ft/ftdbase.cc +++ b/libretroshare/src/ft/ftdbase.cc @@ -134,9 +134,6 @@ bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, Fil } bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, const std::string& peer_id,FileInfo &info) const { - uint64_t fsize; - std::string path; - #ifdef DB_DEBUG std::cerr << "ftFiMonitor::search(" << hash << "," << hintflags; std::cerr << ")"; @@ -149,7 +146,7 @@ bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, con FileSearchFlags flags = hintflags ; flags &= (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE); - if(findLocalFile(hash, flags,peer_id,path, fsize)) + if(findLocalFile(hash, flags,peer_id,info.path, info.size,info.storage_permission_flags,info.parent_groups)) { /* fill in details */ #ifdef DB_DEBUG @@ -158,10 +155,7 @@ bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, con std::cerr << " = " << hash << "," << fsize; std::cerr << std::endl; #endif - - info.size = fsize; - info.fname = RsDirUtil::getTopDir(path); - info.path = path; + info.fname = RsDirUtil::getTopDir(info.path); return true; } diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 372cc5fd6..d031c680b 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -2288,20 +2288,24 @@ bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const std::stri { bool res = rsFiles->FileDetails(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_DOWNLOAD, info); - // The call to computeHashPeerClearance() return a combination of RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE - // This is an additional computation cost, but the way it's written here, it's only called when res is true. - // - res = res && (RS_FILE_HINTS_NETWORK_WIDE & rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups)) ; - std::cerr << "p3turtle: performing local hash search for hash " << hash << std::endl; if(res) { std::cerr << "Found hash: " << std::endl; + std::cerr << " hash = " << hash << std::endl; std::cerr << " peer = " << peer_id << std::endl; + std::cerr << " flags = " << info.storage_permission_flags << std::endl; + std::cerr << " local = " << rsFiles->FileDetails(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_DOWNLOAD, info) << std::endl; + std::cerr << " groups= " ; for(std::list::const_iterator it(info.parent_groups.begin());it!=info.parent_groups.end();++it) std::cerr << (*it) << ", " ; std::cerr << std::endl; std::cerr << " clear = " << rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups) << std::endl; } + // The call to computeHashPeerClearance() return a combination of RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE + // This is an additional computation cost, but the way it's written here, it's only called when res is true. + // + res = res && (RS_FILE_HINTS_NETWORK_WIDE & rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups)) ; + return res ; }