mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-19 03:06:26 +00:00
JSONDB fix.
This commit is contained in:
parent
48cadcd2fc
commit
f6d92eb737
@ -1129,7 +1129,8 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE(
|
||||
} else {
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
printf("%s\n",di->c_str());
|
||||
if ((di->length() > 5)&&(di->substr(di->length() - 5) == ".json")) {
|
||||
this->get(b + di->substr(0,di->length() - 5));
|
||||
} else {
|
||||
|
@ -73,7 +73,7 @@ bool OSUtils::redirectUnixOutputs(const char *stdoutPath,const char *stderrPath)
|
||||
}
|
||||
#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;
|
||||
|
||||
@ -82,7 +82,7 @@ std::vector<std::string> OSUtils::listDirectory(const char *path)
|
||||
WIN32_FIND_DATAA ffd;
|
||||
if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
|
||||
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));
|
||||
} while (FindNextFileA(hFind,&ffd));
|
||||
FindClose(hFind);
|
||||
@ -98,7 +98,7 @@ std::vector<std::string> OSUtils::listDirectory(const char *path)
|
||||
if (readdir_r(d,&de,&dptr))
|
||||
break;
|
||||
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));
|
||||
} else break;
|
||||
}
|
||||
|
@ -104,12 +104,11 @@ public:
|
||||
/**
|
||||
* List a directory's contents
|
||||
*
|
||||
* This returns only files, not sub-directories.
|
||||
*
|
||||
* @param path Path to list
|
||||
* @param includeDirectories If true, include directories as well as files
|
||||
* @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
|
||||
|
Loading…
Reference in New Issue
Block a user