Skip to content

Commit

Permalink
fix hang at initializing xschedule if remote falcon server is not ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
dev8edss authored and dkulp committed Dec 31, 2024
1 parent 81f936e commit f9f0982
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions xSchedule/RemoteFalcon/RemoteFalconMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,23 @@ RemoteFalconFrame::RemoteFalconFrame(wxWindow* parent, const std::string& showDi

if (_options.GetClearQueueOnStart()) {
AddMessage(MESSAGE_LEVEL::ML_INFO, "Clearing remote falcon list of songs.");
int tries = 10;
bool done = false;
do {
auto res = _remoteFalcon->PurgeQueue();
AddMessage(MESSAGE_LEVEL::ML_INFO, " " + res);

wxJSONReader reader;
wxJSONValue val;
reader.Parse(res, &val);

if (!val.IsNull()) {
if (val["message"].AsString() == "Success") {
done = true;
}
else if (val["message"].AsString() == "Unauthorized") {
tries = 1;
AddMessage(MESSAGE_LEVEL::ML_ERROR, "Error: " + val["message"].AsString());
}
}
tries--;
} while (!done && tries > 0);

if (tries == 0) {
logger_base.warn("RemoteFalcon failed to clear existing list of songs.");
auto res = _remoteFalcon->PurgeQueue();

wxJSONReader reader;
wxJSONValue val;
reader.Parse(res, &val);

if (!val.IsNull()) {
if (val["message"].AsString() == "Success") {
AddMessage(MESSAGE_LEVEL::ML_INFO, "Cleared remote falcon list of songs.");
} else {
AddMessage(MESSAGE_LEVEL::ML_ERROR, "Error: " + val["message"].AsString());
}
} else {
AddMessage(MESSAGE_LEVEL::ML_ERROR, "Error: " + val["message"].AsString());
}
}

ValidateWindow();
}

Expand Down

0 comments on commit f9f0982

Please sign in to comment.