refactor: add throw_on_blocked arg to Flame file parse

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-07-21 16:41:44 -03:00
parent 242fb156a2
commit 2246c3359b
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,7 @@ void Flame::loadManifest(Flame::Manifest& m, const QString& filepath)
loadManifestV1(m, obj);
}
bool Flame::File::parseFromObject(const QJsonObject& obj)
bool Flame::File::parseFromObject(const QJsonObject& obj, bool throw_on_blocked)
{
fileName = Json::requireString(obj, "fileName");
// This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience
@ -91,7 +91,7 @@ bool Flame::File::parseFromObject(const QJsonObject& obj)
// may throw, if the project is blocked
QString rawUrl = Json::ensureString(obj, "downloadUrl");
url = QUrl(rawUrl, QUrl::TolerantMode);
if (!url.isValid()) {
if (!url.isValid() && throw_on_blocked) {
throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl));
}

View File

@ -46,7 +46,7 @@ namespace Flame
struct File
{
// NOTE: throws JSONValidationError
bool parseFromObject(const QJsonObject& object);
bool parseFromObject(const QJsonObject& object, bool throw_on_blocked = true);
int projectId = 0;
int fileId = 0;