mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
JSONDB fix.
This commit is contained in:
parent
48cadcd2fc
commit
f6d92eb737
4 changed files with 9 additions and 8 deletions
|
@ -1129,7 +1129,8 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE(
|
||||||
} else {
|
} else {
|
||||||
Mutex::Lock _l(_db_m);
|
Mutex::Lock _l(_db_m);
|
||||||
|
|
||||||
std::string pfx("network/"); pfx.append(nwids);
|
std::string pfx("network/");
|
||||||
|
pfx.append(nwids);
|
||||||
_db.filter(pfx,[](const std::string &n,const json &obj) {
|
_db.filter(pfx,[](const std::string &n,const json &obj) {
|
||||||
return false; // delete
|
return false; // delete
|
||||||
});
|
});
|
||||||
|
|
|
@ -99,8 +99,9 @@ void JSONDB::erase(const std::string &n)
|
||||||
|
|
||||||
void JSONDB::_reload(const std::string &p,const std::string &b)
|
void JSONDB::_reload(const std::string &p,const std::string &b)
|
||||||
{
|
{
|
||||||
std::vector<std::string> dl(OSUtils::listDirectory(p.c_str()));
|
std::vector<std::string> dl(OSUtils::listDirectory(p.c_str(),true));
|
||||||
for(std::vector<std::string>::const_iterator di(dl.begin());di!=dl.end();++di) {
|
for(std::vector<std::string>::const_iterator di(dl.begin());di!=dl.end();++di) {
|
||||||
|
printf("%s\n",di->c_str());
|
||||||
if ((di->length() > 5)&&(di->substr(di->length() - 5) == ".json")) {
|
if ((di->length() > 5)&&(di->substr(di->length() - 5) == ".json")) {
|
||||||
this->get(b + di->substr(0,di->length() - 5));
|
this->get(b + di->substr(0,di->length() - 5));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool OSUtils::redirectUnixOutputs(const char *stdoutPath,const char *stderrPath)
|
||||||
}
|
}
|
||||||
#endif // __UNIX_LIKE__
|
#endif // __UNIX_LIKE__
|
||||||
|
|
||||||
std::vector<std::string> OSUtils::listDirectory(const char *path)
|
std::vector<std::string> OSUtils::listDirectory(const char *path,bool includeDirectories)
|
||||||
{
|
{
|
||||||
std::vector<std::string> r;
|
std::vector<std::string> r;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ std::vector<std::string> OSUtils::listDirectory(const char *path)
|
||||||
WIN32_FIND_DATAA ffd;
|
WIN32_FIND_DATAA ffd;
|
||||||
if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
|
if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
|
||||||
do {
|
do {
|
||||||
if ((strcmp(ffd.cFileName,"."))&&(strcmp(ffd.cFileName,".."))&&((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0))
|
if ( (strcmp(ffd.cFileName,".")) && (strcmp(ffd.cFileName,"..")) && (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)||(((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)&&(includeDirectories))) )
|
||||||
r.push_back(std::string(ffd.cFileName));
|
r.push_back(std::string(ffd.cFileName));
|
||||||
} while (FindNextFileA(hFind,&ffd));
|
} while (FindNextFileA(hFind,&ffd));
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
|
@ -98,7 +98,7 @@ std::vector<std::string> OSUtils::listDirectory(const char *path)
|
||||||
if (readdir_r(d,&de,&dptr))
|
if (readdir_r(d,&de,&dptr))
|
||||||
break;
|
break;
|
||||||
if (dptr) {
|
if (dptr) {
|
||||||
if ((strcmp(dptr->d_name,"."))&&(strcmp(dptr->d_name,".."))&&(dptr->d_type != DT_DIR))
|
if ((strcmp(dptr->d_name,"."))&&(strcmp(dptr->d_name,".."))&&((dptr->d_type != DT_DIR)||(includeDirectories)))
|
||||||
r.push_back(std::string(dptr->d_name));
|
r.push_back(std::string(dptr->d_name));
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,12 +104,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* List a directory's contents
|
* List a directory's contents
|
||||||
*
|
*
|
||||||
* This returns only files, not sub-directories.
|
|
||||||
*
|
|
||||||
* @param path Path to list
|
* @param path Path to list
|
||||||
|
* @param includeDirectories If true, include directories as well as files
|
||||||
* @return Names of files in directory (without path prepended)
|
* @return Names of files in directory (without path prepended)
|
||||||
*/
|
*/
|
||||||
static std::vector<std::string> listDirectory(const char *path);
|
static std::vector<std::string> listDirectory(const char *path,bool includeDirectories = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean a directory of files whose last modified time is older than this
|
* Clean a directory of files whose last modified time is older than this
|
||||||
|
|
Loading…
Add table
Reference in a new issue