summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Grulich <[email protected]>2017-03-23 10:03:05 +0100
committerJan Grulich <[email protected]>2017-03-23 10:03:05 +0100
commit850cdbe85d043dc78222944361b3150c1fa5715c (patch)
treeecaf63c20e4f249d6ed7e5a453e211c1608b5957
parent51f82e97ad7edcd7f57d906407bac38c3ba65c75 (diff)
ODRS backend: download ratings to ratings subdir
-rw-r--r--libdiscover/ReviewsBackend/OdrsReviewsBackend.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libdiscover/ReviewsBackend/OdrsReviewsBackend.cpp b/libdiscover/ReviewsBackend/OdrsReviewsBackend.cpp
index cab997e..be3d9ab 100644
--- a/libdiscover/ReviewsBackend/OdrsReviewsBackend.cpp
+++ b/libdiscover/ReviewsBackend/OdrsReviewsBackend.cpp
@@ -31,6 +31,7 @@
#include <KUser>
#include <QCryptographicHash>
+#include <QDir>
#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
@@ -48,7 +49,11 @@ OdrsReviewsBackend::OdrsReviewsBackend(AbstractResourcesBackend *parent)
{
bool fetchRatings = false;
const QUrl ratingsUrl(QStringLiteral("https://odrs.gnome.org/1.0/reviews/api/ratings"));
- const QUrl fileUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/ratings"));
+ const QUrl fileUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/ratings/ratings"));
+ const QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
+
+ // Create $HOME/.cache/discover/ratings folder
+ cacheDir.mkdir(QStringLiteral("ratings"));
if (QFileInfo::exists(fileUrl.toLocalFile())) {
QFileInfo file(fileUrl.toLocalFile());
@@ -279,7 +284,7 @@ void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply)
void OdrsReviewsBackend::parseRatings()
{
- QFile ratingsDocument(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/ratings"));
+ QFile ratingsDocument(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/ratings/ratings"));
if (ratingsDocument.open(QIODevice::ReadOnly)) {
QJsonDocument jsonDocument = QJsonDocument::fromJson(ratingsDocument.readAll());
QJsonObject jsonObject = jsonDocument.object();