refactor: add throw_on_blocked
arg to Flame file parse
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
242fb156a2
commit
2246c3359b
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user