diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 77126fdb9..7756d7759 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -87,17 +87,24 @@ int FileIndexMonitor::filterResults(std::list& firesults,std::list::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit) { - DirDetails pdetails ; - RequestDirDetails((*rit)->parent,pdetails,0) ; DirDetails cdetails ; RequestDirDetails (*rit,cdetails,0); +#ifdef FIM_DEBUG + std::cerr << "Filtering candidate " << (*rit)->name << ", flags=" << cdetails.flags ; +#endif - if ( ((cdetails.type == DIR_TYPE_FILE) && (pdetails.flags & flags & (DIR_FLAGS_BROWSABLE | DIR_FLAGS_NETWORK_WIDE)) > 0) || - ((cdetails.type == DIR_TYPE_DIR) && (cdetails.flags & flags & (DIR_FLAGS_BROWSABLE | DIR_FLAGS_NETWORK_WIDE)) > 0) ) + if (cdetails.type == DIR_TYPE_FILE && ( cdetails.flags & flags & (DIR_FLAGS_BROWSABLE | DIR_FLAGS_NETWORK_WIDE)) > 0) { cdetails.id = "Local"; results.push_back(cdetails); +#ifdef FIM_DEBUG + std::cerr << ": kept" << std::endl ; +#endif } +#ifdef FIM_DEBUG + else + std::cerr << ": discarded" << std::endl ; +#endif } return !results.empty() ; } @@ -1029,26 +1036,26 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t return false ; // look for the top level and setup flags accordingly + // The top level directory is the first dir in parents for which + // dir->parent->parent == NULL if(ref != NULL) { FileEntry *file = (FileEntry *) ref; - DirEntry *dir = dynamic_cast(file->parent) ; - DirEntry *last_dir = NULL ; + DirEntry *dir = dynamic_cast(file) ; + if(dir == NULL) + dir = dynamic_cast(file->parent) ; - if(dir != NULL) - while(dir->parent != NULL) - { - last_dir = dir ; + if(dir != NULL && dir->parent != NULL) + while(dir->parent->parent != NULL) dir = dir->parent ; - } - if(last_dir != NULL) + if(dir != NULL && dir->parent != NULL) { #ifdef FIM_DEBUG - std::cerr << "FileIndexMonitor::RequestDirDetails: parent->name=" << last_dir->name << std::endl ; + std::cerr << "FileIndexMonitor::RequestDirDetails: top parent name=" << dir->name << std::endl ; #endif - std::map::const_iterator it = directoryMap.find(last_dir->name) ; + std::map::const_iterator it = directoryMap.find(dir->name) ; if(it == directoryMap.end()) std::cerr << "*********** ERROR *********** In " << __PRETTY_FUNCTION__ << std::endl ; diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 681436df2..d5d1b8988 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -1521,15 +1521,27 @@ void RsTurtleStringSearchRequestItem::performLocalSearch(std::listsearch()" << std::endl ; +#endif // now, search! rsFiles->SearchKeywords(words, initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE); +#ifdef P3TURTLE_DEBUG + std::cerr << initialResults.size() << " matches found." << std::endl ; +#endif result.clear() ; for(std::list::const_iterator it(initialResults.begin());it!=initialResults.end();++it) { // retain only file type - if (it->type == DIR_TYPE_DIR) continue; + if (it->type == DIR_TYPE_DIR) + { +#ifdef P3TURTLE_DEBUG + std::cerr << " Skipping directory " << it->name << std::endl ; +#endif + continue; + } TurtleFileInfo i ; i.hash = it->hash ; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 73881880a..610a50862 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -964,6 +964,8 @@ void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std:: std::cerr << "Size: " << details.count << std::endl; std::cerr << "Path: " << details.path << std::endl; #endif + // Note: for directories, the returned hash, is the peer id, so if we collect + // dirs, we need to be a bit more conservative for the if(already_in.find(details.hash+details.name) == already_in.end()) {