mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 07:35:12 -04:00
factorized and cleaned the common code between fistore.cc and fimonitor.cc, improved the stability of FileIndex, improved the display in RemoteDirModel
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2158 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dd5e058173
commit
8e5b1dca64
6 changed files with 321 additions and 358 deletions
|
@ -261,10 +261,18 @@ void FileIndexMonitor::run()
|
|||
{
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
RsStackMutex mtx(fiMutex) ;
|
||||
std::cerr <<"*********** FileIndex **************" << std::endl ;
|
||||
fi.printFileIndex(std::cerr) ;
|
||||
std::cerr <<"************** END *****************" << std::endl ;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// updateCycle(current_job);
|
||||
updateCycle();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -987,46 +995,75 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t
|
|||
fi.root->checkParentPointers();
|
||||
#endif
|
||||
|
||||
// return details as reported by the FileIndex
|
||||
// If ref is NULL, we build a root node
|
||||
|
||||
bool b = fi.RequestDirDetails(ref,details,flags) ;
|
||||
if (ref == NULL)
|
||||
{
|
||||
#ifdef FI_DEBUG
|
||||
std::cerr << "FileIndex::RequestDirDetails() ref=NULL (root)" << std::endl;
|
||||
#endif
|
||||
/* local only */
|
||||
DirStub stub;
|
||||
stub.type = DIR_TYPE_PERSON;
|
||||
stub.name = fi.root->name;
|
||||
stub.ref = fi.root;
|
||||
details.children.push_back(stub);
|
||||
details.count = 1;
|
||||
|
||||
details.parent = NULL;
|
||||
details.prow = -1;
|
||||
details.ref = NULL;
|
||||
details.type = DIR_TYPE_ROOT;
|
||||
details.name = "root";
|
||||
details.hash = "";
|
||||
details.path = "root";
|
||||
details.age = 0;
|
||||
details.flags = 0;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool b = FileIndex::extractData(ref,details) ;
|
||||
|
||||
if(!b)
|
||||
return false ;
|
||||
|
||||
// look for the top level and setup flags accordingly
|
||||
|
||||
FileEntry *file = (FileEntry *) ref;
|
||||
DirEntry *dir = dynamic_cast<DirEntry *>(file);
|
||||
DirEntry *last_dir = NULL ;
|
||||
|
||||
if(dir != NULL)
|
||||
while(dir->parent != NULL)
|
||||
{
|
||||
last_dir = dir ;
|
||||
dir = dir->parent ;
|
||||
}
|
||||
|
||||
if(last_dir != NULL)
|
||||
if(ref != NULL)
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::RequestDirDetails: parent->name=" << last_dir->name << std::endl ;
|
||||
#endif
|
||||
std::map<std::string,SharedDirInfo>::const_iterator it = directoryMap.find(last_dir->name) ;
|
||||
FileEntry *file = (FileEntry *) ref;
|
||||
DirEntry *dir = dynamic_cast<DirEntry*>(file->parent) ;
|
||||
DirEntry *last_dir = NULL ;
|
||||
|
||||
if(it == directoryMap.end())
|
||||
std::cerr << "*********** ERROR *********** In " << __PRETTY_FUNCTION__ << std::endl ;
|
||||
else
|
||||
if(dir != NULL)
|
||||
while(dir->parent != NULL)
|
||||
{
|
||||
last_dir = dir ;
|
||||
dir = dir->parent ;
|
||||
}
|
||||
|
||||
if(last_dir != NULL)
|
||||
{
|
||||
details.flags |= (( (it->second.shareflags & RS_FILE_HINTS_BROWSABLE)>0)?DIR_FLAGS_BROWSABLE:0) ;
|
||||
details.flags |= (( (it->second.shareflags & RS_FILE_HINTS_NETWORK_WIDE)>0)?DIR_FLAGS_NETWORK_WIDE:0) ;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "flags = " << details.flags << std::endl ;
|
||||
std::cerr << "FileIndexMonitor::RequestDirDetails: parent->name=" << last_dir->name << std::endl ;
|
||||
#endif
|
||||
std::map<std::string,SharedDirInfo>::const_iterator it = directoryMap.find(last_dir->name) ;
|
||||
|
||||
if(it == directoryMap.end())
|
||||
std::cerr << "*********** ERROR *********** In " << __PRETTY_FUNCTION__ << std::endl ;
|
||||
else
|
||||
{
|
||||
details.flags |= (( (it->second.shareflags & RS_FILE_HINTS_BROWSABLE)>0)?DIR_FLAGS_BROWSABLE:0) ;
|
||||
details.flags |= (( (it->second.shareflags & RS_FILE_HINTS_NETWORK_WIDE)>0)?DIR_FLAGS_NETWORK_WIDE:0) ;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "flags = " << details.flags << std::endl ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return b ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue