Browse Source

Add commented-out warning for invalid or duplicate module tags.

tags/v2.6.0
Andrew Belt 8 months ago
parent
commit
73431fd235
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      src/plugin/Model.cpp

+ 9
- 4
src/plugin/Model.cpp View File

@@ -24,7 +24,7 @@ void Model::fromJson(json_t* rootJ) {
if (nameJ) if (nameJ)
name = json_string_value(nameJ); name = json_string_value(nameJ);
if (name == "") if (name == "")
throw Exception("No module name for slug %s", slug.c_str());
throw Exception("Module %s/%s has no name", plugin->slug.c_str(), slug.c_str());


json_t* descriptionJ = json_object_get(rootJ, "description"); json_t* descriptionJ = json_object_get(rootJ, "description");
if (descriptionJ) if (descriptionJ)
@@ -39,14 +39,19 @@ void Model::fromJson(json_t* rootJ) {
json_array_foreach(tagsJ, i, tagJ) { json_array_foreach(tagsJ, i, tagJ) {
std::string tag = json_string_value(tagJ); std::string tag = json_string_value(tagJ);
int tagId = tag::findId(tag); int tagId = tag::findId(tag);
if (tagId < 0) {
// WARN("Module %s/%s has invalid tag \"%s\"", plugin->slug.c_str(), slug.c_str(), tag.c_str());
continue;
}


// Omit duplicates // Omit duplicates
auto it = std::find(tagIds.begin(), tagIds.end(), tagId); auto it = std::find(tagIds.begin(), tagIds.end(), tagId);
if (it != tagIds.end())
if (it != tagIds.end()) {
// WARN("Module %s/%s has duplicate tag \"%s\"", plugin->slug.c_str(), slug.c_str(), tag.c_str());
continue; continue;
}


if (tagId >= 0)
tagIds.push_back(tagId);
tagIds.push_back(tagId);
} }
} }




Loading…
Cancel
Save