提交 704a6290 authored 作者: blu's avatar blu

upload video files

上级 b718c2f5
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
], ],
"evpusher":[ "evpusher":[
{ {
"enabled":1, "enabled":0,
"iid":1, "iid":1,
"password":"", "password":"",
"sn":"PSBV7GKN", "sn":"PSBV7GKN",
......
...@@ -19,9 +19,9 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -19,9 +19,9 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
ret["msg"] = "ok"; ret["msg"] = "ok";
ret["data"] = json(); ret["data"] = json();
bool hasError = false; bool hasError = false;
spdlog::info("matching {}", diff.dump()); spdlog::info("matching {}, size:{}, type:{}", diff.dump(), diff.size(), diff.type_name());
try{ try{
for(auto &d: diff.array()) { for(auto &d: diff) {
spdlog::info("d :{}, {}", d.dump(), d.size()); spdlog::info("d :{}, {}", d.dump(), d.size());
if(d.count("path") != 0) { if(d.count("path") != 0) {
string path_ = d["path"]; string path_ = d["path"];
...@@ -35,10 +35,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -35,10 +35,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
string ipcRegStr = string("/") + sn + "/ipcs/(\\d+)/(\\w+)"; string ipcRegStr = string("/") + sn + "/ipcs/(\\d+)/(\\w+)";
std::smatch results; std::smatch results;
std::regex ipcRegex(ipcRegStr); std::regex ipcRegex(ipcRegStr);
spdlog::info("x diff: {}", diff.dump());
if (std::regex_match(path_, results, ipcRegex)) { if (std::regex_match(path_, results, ipcRegex)) {
if (results.size() == 3) { if (results.size() == 3) {
spdlog::info("matched ipc: {}",path_);
matched = true; matched = true;
int ipcIdx = stoi(results[1].str()); int ipcIdx = stoi(results[1].str());
string tag = results[2].str(); string tag = results[2].str();
...@@ -76,14 +74,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -76,14 +74,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
} }
} }
} }
}else{
for(auto &i: results) {
spdlog::info("\t{}", i.str());
}
} }
}else{
spdlog::info("no match for ipc", path_);
} }
// else{
// spdlog::info("no match for ipc", path_);
// }
// match module config // match module config
if(!matched && !hasError) { if(!matched && !hasError) {
...@@ -93,14 +88,13 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -93,14 +88,13 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
std::smatch results2; std::smatch results2;
if (std::regex_match(path_, results2, moduleRegex)) { if (std::regex_match(path_, results2, moduleRegex)) {
if (results2.size() == 5) { if (results2.size() == 5) {
spdlog::info("matched module: {}",path_);
int ipcIdx = stoi(results2[1].str()); int ipcIdx = stoi(results2[1].str());
int modIdx = stoi(results[3].str()); int modIdx = stoi(results2[3].str());
string modName = results[2].str(); string modName = results2[2].str();
string propName = results[4].str(); string propName = results2[4].str();
if(d["op"] == "replace"||d["op"] == "add") { if(d["op"] == "replace"||d["op"] == "add") {
auto &oldMod = oldConfig[sn]["ipcs"][ipcIdx]["modules"][modIdx]; auto &oldMod = oldConfig[sn]["ipcs"][ipcIdx]["modules"][modName][modIdx];
auto &newMod = newConfig[sn]["ipcs"][ipcIdx]["modules"][modIdx]; auto &newMod = newConfig[sn]["ipcs"][ipcIdx]["modules"][modName][modIdx];
if(oldMod.count("iid") == 0 || newMod.count("iid") == 0) { if(oldMod.count("iid") == 0 || newMod.count("iid") == 0) {
string msg = fmt::format("invalid module config ipcs[{}]['modules'][{}][{}] having no iid field", ipcIdx, modName, modIdx); string msg = fmt::format("invalid module config ipcs[{}]['modules'][{}][{}] having no iid field", ipcIdx, modName, modIdx);
spdlog::error(msg); spdlog::error(msg);
...@@ -119,8 +113,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -119,8 +113,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
} }
} }
string oldGid = sn + ":" + modName + ":" + oldMod["iid"].get<string>(); string oldGid = sn + ":" + modName + ":" + to_string(oldMod["iid"].get<int>());
string newGid = sn + ":" + modName + ":" + newMod["iid"].get<string>(); string newGid = sn + ":" + modName + ":" + to_string(newMod["iid"].get<int>());
if(oldGid != newGid) { if(oldGid != newGid) {
ret["data"][oldGid] = 0; ret["data"][oldGid] = 0;
...@@ -130,10 +124,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -130,10 +124,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
if(newMod["enabled"].get<int>() == 0) { if(newMod["enabled"].get<int>() == 0) {
ret["data"][newGid] = 0; ret["data"][newGid] = 0;
}else{ }else{
ret["data"][newGid] = 2; ret["data"][newGid] = 1;
} }
}else{ }else{ // other prop modification
// disabled // it was disabled. just ignore
if(ret["data"].count(newGid) != 0 && ret["data"][newGid].get<int>() == 0) { if(ret["data"].count(newGid) != 0 && ret["data"][newGid].get<int>() == 0) {
// nop // nop
}else{ }else{
...@@ -143,14 +137,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -143,14 +137,11 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
} }
} }
} }
}else{
for(auto &i: results) {
spdlog::info("\t{}", i.str());
}
} }
}else{
spdlog::info("no match for module {}", path_);
} }
// else{
// spdlog::info("no match for module {}", path_);
// }
} }
if(hasError){ if(hasError){
...@@ -176,7 +167,7 @@ int main(){ ...@@ -176,7 +167,7 @@ int main(){
config = config["data"]; config = config["data"];
iff2 >> config2; iff2 >> config2;
config2 = config2["data"]; config2 = config2["data"];
json dif = json::diff(config2, config).dump(); json dif = json::diff(config2, config);
spdlog::info("diff: {}", dif.dump()); spdlog::info("diff: {}", dif.dump());
auto ret = getModulesOperFromConfDiff(config2, config, dif, "PSBV7GKN"); auto ret = getModulesOperFromConfDiff(config2, config, dif, "PSBV7GKN");
spdlog::info("parse: {}", ret.dump()); spdlog::info("parse: {}", ret.dump());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论