Perform at least some checks before sending config
This commit is contained in:
parent
b92bf4f27a
commit
bf4b26c6f8
|
@ -673,11 +673,26 @@ void Application::editConfig(const ArgumentOccurrence &)
|
||||||
<< " at character " << error.offset << endl;
|
<< " at character " << error.offset << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// perform at least some checks before sending the configuration
|
||||||
const auto configObj(configDoc.object());
|
const auto configObj(configDoc.object());
|
||||||
if (configObj.isEmpty()) {
|
if (configObj.isEmpty()) {
|
||||||
cerr << Phrases::Error << "New config object seems empty." << Phrases::EndFlush;
|
cerr << Phrases::Error << "New config object seems empty." << Phrases::EndFlush;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (const auto &arrayName : {QStringLiteral("devices"), QStringLiteral("folders")}) {
|
||||||
|
if (!configObj.value(arrayName).isArray()) {
|
||||||
|
cerr << Phrases::Error << "Array \"" << arrayName.toLocal8Bit().data() << "\" is not present." << Phrases::EndFlush;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &objectName : {QStringLiteral("options"), QStringLiteral("gui")}) {
|
||||||
|
if (!configObj.value(objectName).isObject()) {
|
||||||
|
cerr << Phrases::Error << "Object \"" << objectName.toLocal8Bit().data() << "\" is not present." << Phrases::EndFlush;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handle "dry-run" case
|
// handle "dry-run" case
|
||||||
if (m_args.dryRun.isPresent()) {
|
if (m_args.dryRun.isPresent()) {
|
||||||
cout << newConfig.data() << flush;
|
cout << newConfig.data() << flush;
|
||||||
|
|
Loading…
Reference in New Issue