mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed fill of the shared files when removing a directory from share.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6999 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dacec52e4f
commit
8ef40bd944
@ -906,7 +906,6 @@ void FileIndexMonitor::updateCycle()
|
||||
}
|
||||
|
||||
if (cleanedCount > 0) {
|
||||
// cb->notifyListPreChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
}
|
||||
}
|
||||
@ -1437,76 +1436,88 @@ bool FileIndexMonitor::inDirectoryCheck()
|
||||
bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
{
|
||||
int i;
|
||||
RsStackMutex stack(fiMutex) ; /* LOCKED DIRS */
|
||||
bool changed = false;
|
||||
|
||||
if (!pendingDirs)
|
||||
{
|
||||
if (mForceCheck)
|
||||
RsStackMutex stack(fiMutex) ; /* LOCKED DIRS */
|
||||
|
||||
if (!pendingDirs)
|
||||
{
|
||||
mForceCheck = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
mForceCheck = false;
|
||||
pendingDirs = false;
|
||||
pendingForceCacheWrite = true;
|
||||
|
||||
/* clear old directories */
|
||||
directoryMap.clear();
|
||||
|
||||
/* iterate through the directories */
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::map<std::string, SharedDirInfo>::const_iterator cit;
|
||||
for(it = pendingDirList.begin(); it != pendingDirList.end(); it++)
|
||||
{
|
||||
/* get the head directory */
|
||||
std::string root_dir = (*it).filename;
|
||||
std::string top_dir = it->virtualname;
|
||||
if (top_dir.empty()) {
|
||||
top_dir = RsDirUtil::getTopDir(root_dir);
|
||||
}
|
||||
|
||||
/* if unique -> add, else add modifier */
|
||||
bool unique = false;
|
||||
for(i = 0; !unique; i++)
|
||||
{
|
||||
std::string tst_dir = top_dir;
|
||||
if (i > 0)
|
||||
if (mForceCheck)
|
||||
{
|
||||
rs_sprintf_append(tst_dir, "-%d", i);
|
||||
mForceCheck = false;
|
||||
return true;
|
||||
}
|
||||
if (directoryMap.end()== (cit=directoryMap.find(tst_dir)))
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
mForceCheck = false;
|
||||
pendingDirs = false;
|
||||
pendingForceCacheWrite = true;
|
||||
|
||||
/* clear old directories */
|
||||
directoryMap.clear();
|
||||
|
||||
/* iterate through the directories */
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::map<std::string, SharedDirInfo>::const_iterator cit;
|
||||
for(it = pendingDirList.begin(); it != pendingDirList.end(); it++)
|
||||
{
|
||||
/* get the head directory */
|
||||
std::string root_dir = (*it).filename;
|
||||
std::string top_dir = it->virtualname;
|
||||
if (top_dir.empty()) {
|
||||
top_dir = RsDirUtil::getTopDir(root_dir);
|
||||
}
|
||||
|
||||
/* if unique -> add, else add modifier */
|
||||
bool unique = false;
|
||||
for(i = 0; !unique; i++)
|
||||
{
|
||||
unique = true;
|
||||
/* store calculated name */
|
||||
it->virtualname = tst_dir;
|
||||
/* add it! */
|
||||
directoryMap[tst_dir.c_str()] = *it;
|
||||
std::string tst_dir = top_dir;
|
||||
if (i > 0)
|
||||
{
|
||||
rs_sprintf_append(tst_dir, "-%d", i);
|
||||
}
|
||||
if (directoryMap.end()== (cit=directoryMap.find(tst_dir)))
|
||||
{
|
||||
unique = true;
|
||||
/* store calculated name */
|
||||
it->virtualname = tst_dir;
|
||||
/* add it! */
|
||||
directoryMap[tst_dir.c_str()] = *it;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "Added [" << tst_dir << "] => " << root_dir << std::endl;
|
||||
std::cerr << "Added [" << tst_dir << "] => " << root_dir << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pendingDirList.clear();
|
||||
|
||||
/* now we've decided on the 'root' dirs set them to the
|
||||
* fileIndex
|
||||
*/
|
||||
std::list<std::string> topdirs;
|
||||
for(cit = directoryMap.begin(); cit != directoryMap.end(); cit++)
|
||||
{
|
||||
topdirs.push_back(cit->first);
|
||||
}
|
||||
|
||||
if (fi.setRootDirectories(topdirs, 0) > 0)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
|
||||
locked_saveFileIndexes(true) ;
|
||||
}
|
||||
|
||||
pendingDirList.clear();
|
||||
|
||||
/* now we've decided on the 'root' dirs set them to the
|
||||
* fileIndex
|
||||
*/
|
||||
std::list<std::string> topdirs;
|
||||
for(cit = directoryMap.begin(); cit != directoryMap.end(); cit++)
|
||||
if (changed)
|
||||
{
|
||||
topdirs.push_back(cit->first);
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0);
|
||||
}
|
||||
|
||||
fi.setRootDirectories(topdirs, 0);
|
||||
|
||||
locked_saveFileIndexes(true) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ int FileIndex::setRootDirectories(const std::list<std::string> &inlist, time_t u
|
||||
}
|
||||
|
||||
/* remove all dirs with zero time (non recursive) */
|
||||
root->removeOldEntries(utime, false);
|
||||
int cleanedCount = root->removeOldEntries(utime, false);
|
||||
|
||||
/* now flag remaining directories with correct update time */
|
||||
for(it = root->subdirs.begin(); it != root->subdirs.end(); it++)
|
||||
@ -569,7 +569,7 @@ int FileIndex::setRootDirectories(const std::list<std::string> &inlist, time_t u
|
||||
|
||||
updateHashIndex() ;
|
||||
|
||||
return 1;
|
||||
return cleanedCount;
|
||||
}
|
||||
|
||||
void FileIndex::updateHashIndex()
|
||||
|
Loading…
Reference in New Issue
Block a user