Verified Commit e174e158 authored by azubieta's avatar azubieta
Browse files

Only set metadata fields when the data is available

parent 67a14d3c
Pipeline #609 passed with stage
in 1 minute and 49 seconds
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
#include <QDebug> #include <QDebug>
#include <KFileMetaData/Properties>
// local // local
#include "AppImageExtractor.h" #include "AppImageExtractor.h"
...@@ -42,14 +43,19 @@ void KFileMetaData::AppImageExtractor::extract(ExtractionResult* result) { ...@@ -42,14 +43,19 @@ void KFileMetaData::AppImageExtractor::extract(ExtractionResult* result) {
QJsonDocument document = QJsonDocument::fromJson(response.toLocal8Bit()); QJsonDocument document = QJsonDocument::fromJson(response.toLocal8Bit());
QJsonObject root = document.object(); QJsonObject root = document.object();
QJsonValue nameValue = root.value("name"); QString nameValue = root.value("name").toString();
result->add(Property::Title, nameValue.toVariant()); if (!nameValue.isEmpty())
result->add(Property::Title, nameValue);
QJsonValue summary = root.value("summary"); // Property::Description is not supported until KF5 5.53.0
result->add(Property::Description, summary.toString()); QString summary = root.value("summary").toString();
if (!summary.isEmpty())
result->add(Property::Description, summary);
QJsonValue license = root.value("license");
result->add(Property::License, license.toString()); QString license = root.value("license").toString();
if (!license.isEmpty())
result->add(Property::License, license);
QJsonValue links = root.value("links"); QJsonValue links = root.value("links");
QJsonObject linksOjbect = links.toObject();; QJsonObject linksOjbect = links.toObject();;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment