Showing the changes to libraries/script-engine/src/ScriptCache.cpp (1 of 8 files). Show all
Unified · Split
| @@ -16,16 +16,20 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <QNetworkReply> |
| 17 | 17 | #include <QObject> |
| 18 | 18 | |
| 19 | +#include <assert.h> | |
| 19 | 20 | #include <NetworkAccessManager.h> |
| 20 | 21 | #include <SharedUtil.h> |
| 21 | −#include "ScriptEngineLogging.h" | |
| 22 | + | |
| 22 | 23 | #include "ScriptCache.h" |
| 24 | +#include "ScriptEngineLogging.h" | |
| 23 | 25 | |
| 24 | 26 | ScriptCache::ScriptCache(QObject* parent) { |
| 25 | 27 | // nothing to do here... |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | −QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending) { | |
| 30 | +QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool redownload) { | |
| 31 | + assert(!_scriptCache.contains(url) || !redownload); | |
| 32 | + | |
| 29 | 33 | QString scriptContents; |
| 30 | 34 | if (_scriptCache.contains(url)) { |
| 31 | 35 | qCDebug(scriptengine) << "Found script in cache:" << url.toString(); |
| @@ -43,8 +47,13 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 11 unmodified lines | ||
| 43 | 47 | QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); |
| 44 | 48 | QNetworkRequest networkRequest = QNetworkRequest(url); |
| 45 | 49 | networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); |
| 50 | + if (redownload) { | |
| 51 | + networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork); | |
| 52 | + qCDebug(scriptengine) << "Redownloading script at:" << url.toString(); | |
| 53 | + } else { | |
| 54 | + qCDebug(scriptengine) << "Downloading script at:" << url.toString(); | |
| 55 | + } | |
| 46 | 56 | |
| 47 | − qCDebug(scriptengine) << "Downloading script at:" << url.toString(); | |
| 48 | 57 | QNetworkReply* reply = networkAccessManager.get(networkRequest); |
| 49 | 58 | connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded); |
| 50 | 59 | } |