mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 09:11:06 -04:00
added infrastructure to add a ignore list in shared files
This commit is contained in:
parent
160ab7b4f3
commit
884b3a6220
11 changed files with 216 additions and 11 deletions
|
@ -81,6 +81,17 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
|||
addSerialType(new RsFileListsSerialiser()) ;
|
||||
}
|
||||
|
||||
void p3FileDatabase::setIgnoreLists(const std::list<std::string>& ignored_prefixes,const std::list<std::string>& ignored_suffixes, uint32_t ignore_flags)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
mLocalDirWatcher->setIgnoreLists(ignored_prefixes,ignored_suffixes,ignore_flags) ;
|
||||
}
|
||||
bool p3FileDatabase::getIgnoreLists(std::list<std::string>& ignored_prefixes,std::list<std::string>& ignored_suffixes, uint32_t& ignore_flags)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
return mLocalDirWatcher->getIgnoreLists(ignored_prefixes,ignored_suffixes,ignore_flags) ;
|
||||
}
|
||||
|
||||
RsSerialiser *p3FileDatabase::setupSerialiser()
|
||||
{
|
||||
// This one is for saveList/loadList
|
||||
|
@ -345,6 +356,28 @@ cleanup = true;
|
|||
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
{
|
||||
std::list<std::string> prefix_list,suffix_list;
|
||||
uint32_t flags ;
|
||||
|
||||
mLocalDirWatcher->getIgnoreLists(prefix_list,suffix_list,flags) ;
|
||||
|
||||
std::string prefix_string, suffix_string ;
|
||||
|
||||
for(auto it(prefix_list.begin());it!=prefix_list.end();++it) prefix_string += *it + ";" ;
|
||||
for(auto it(suffix_list.begin());it!=suffix_list.end();++it) suffix_string += *it + ";" ;
|
||||
|
||||
RsTlvKeyValue kv;
|
||||
|
||||
kv.key = IGNORED_PREFIXES_SS; kv.value = prefix_string; rskv->tlvkvs.pairs.push_back(kv);
|
||||
kv.key = IGNORED_SUFFIXES_SS; kv.value = suffix_string; rskv->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
std::string s ;
|
||||
rs_sprintf(s, "%lu", flags) ;
|
||||
|
||||
kv.key = IGNORE_LIST_FLAGS_SS; kv.value = s; rskv->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
/* Add KeyValue to saveList */
|
||||
sList.push_back(rskv);
|
||||
|
||||
|
@ -363,6 +396,8 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||
#endif
|
||||
|
||||
std::list<SharedDirInfo> dirList;
|
||||
std::list<std::string> ignored_prefixes,ignored_suffixes ;
|
||||
uint32_t ignore_flags ;
|
||||
|
||||
for(std::list<RsItem *>::iterator it = load.begin(); it != load.end(); ++it)
|
||||
{
|
||||
|
@ -400,6 +435,31 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << "Initing directory watcher with saved secret salt..." << std::endl;
|
||||
mLocalDirWatcher->setHashSalt(RsFileHash(kit->value)) ;
|
||||
}
|
||||
else if(kit->key == IGNORED_PREFIXES_SS)
|
||||
{
|
||||
std::string b ;
|
||||
for(uint32_t i=0;i<kit->value.size();++i)
|
||||
if(kit->value[i] == ';')
|
||||
ignored_prefixes.push_back(b) ;
|
||||
else
|
||||
b.push_back(kit->value[i]) ;
|
||||
}
|
||||
else if(kit->key == IGNORED_SUFFIXES_SS)
|
||||
{
|
||||
std::string b ;
|
||||
for(uint32_t i=0;i<kit->value.size();++i)
|
||||
if(kit->value[i] == ';')
|
||||
ignored_suffixes.push_back(b) ;
|
||||
else
|
||||
b.push_back(kit->value[i]) ;
|
||||
}
|
||||
else if(kit->key == IGNORE_LIST_FLAGS_SS)
|
||||
{
|
||||
int t=0 ;
|
||||
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
||||
ignore_flags = (uint32_t)t ;
|
||||
}
|
||||
|
||||
delete *it ;
|
||||
continue ;
|
||||
}
|
||||
|
@ -427,6 +487,8 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
|||
|
||||
/* set directories */
|
||||
mLocalSharedDirs->setSharedDirectoryList(dirList);
|
||||
mLocalDirWatcher->setIgnoreLists(ignored_prefixes,ignored_suffixes,ignore_flags) ;
|
||||
|
||||
load.clear() ;
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue