Skip to content

Commit

Permalink
Abort if server was not found
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Mar 24, 2023
1 parent f6c73ee commit 1bb77f5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/cmd/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ int main(int argc, char **argv)
// Perform a call to get the capabilities.
auto *capabilitiesJob = new JsonApiJob(ctx.account, QStringLiteral("ocs/v1.php/cloud/capabilities"), {}, {}, nullptr);
QObject::connect(capabilitiesJob, &JsonApiJob::finishedSignal, qApp, [capabilitiesJob, ctx] {
if (capabilitiesJob->reply()->error() != QNetworkReply::NoError || capabilitiesJob->httpStatusCode() != 200) {
qCritical() << "Error connecting to server";
exit(1);
}
auto caps = capabilitiesJob->data().value(QStringLiteral("ocs")).toObject().value(QStringLiteral("data")).toObject().value(QStringLiteral("capabilities")).toObject();
qDebug() << "Server capabilities" << caps;
ctx.account->setCapabilities(caps.toVariantMap());
Expand All @@ -492,11 +496,6 @@ int main(int argc, char **argv)
exit(1);
}

if (capabilitiesJob->reply()->error() != QNetworkReply::NoError) {
qCritical() << "Error connecting to server";
exit(1);
}

auto userJob = new JsonApiJob(ctx.account, QStringLiteral("ocs/v1.php/cloud/user"), {}, {}, nullptr);
QObject::connect(userJob, &JsonApiJob::finishedSignal, qApp, [userJob, ctx] {
const QJsonObject data = userJob->data().value(QStringLiteral("ocs")).toObject().value(QStringLiteral("data")).toObject();
Expand Down

0 comments on commit 1bb77f5

Please sign in to comment.