1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Suppress networks error during the update check

This commit is contained in:
Dmitry Vedenko 2021-06-29 14:24:52 +03:00 committed by Paul Licameli
parent 6ef767282d
commit a5d74f564d
2 changed files with 28 additions and 19 deletions

View File

@ -65,34 +65,43 @@ VersionPatch UpdateManager::GetVersionPatch() const
return mVersionPatch;
}
void UpdateManager::GetUpdates()
void UpdateManager::GetUpdates(bool ignoreNetworkErrors)
{
const audacity::network_manager::Request request("https://updates.audacityteam.org/feed/latest.xml");
auto response = audacity::network_manager::NetworkManager::GetInstance().doGet(request);
response->setRequestFinishedCallback([response, this](audacity::network_manager::IResponse*) {
response->setRequestFinishedCallback([response, ignoreNetworkErrors, this](audacity::network_manager::IResponse*) {
auto gAudioIO = AudioIO::Get();
if (response->getError() != audacity::network_manager::NetworkError::NoError)
{
gAudioIO->CallAfterRecording([] {ShowExceptionDialog(nullptr,
XC("Error checking for update", "update dialog"),
XC("Unable to connect to Audacity update server.", "update dialog"),
wxString());
});
return;
if (!ignoreNetworkErrors)
{
gAudioIO->CallAfterRecording([] {
ShowExceptionDialog(
nullptr, XC("Error checking for update", "update dialog"),
XC("Unable to connect to Audacity update server.",
"update dialog"),
wxString());
});
}
return;
}
if (!mUpdateDataParser.Parse(response->readAll<VersionPatch::UpdateDataFormat>(), &mVersionPatch))
{
gAudioIO->CallAfterRecording([] {ShowExceptionDialog(nullptr,
XC("Error checking for update", "update dialog"),
XC("Update data was corrupted.", "update dialog"),
wxString());
});
return;
if (!ignoreNetworkErrors)
{
gAudioIO->CallAfterRecording([] {
ShowExceptionDialog(
nullptr, XC("Error checking for update", "update dialog"),
XC("Update data was corrupted.", "update dialog"),
wxString());
});
}
return;
}
if (mVersionPatch.version > CurrentBuildVersion())
@ -113,7 +122,7 @@ void UpdateManager::GetUpdates()
}
});
}
});
});
}
void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
@ -121,7 +130,7 @@ void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
bool updatesCheckingEnabled = UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Read();
if (updatesCheckingEnabled && IsTimeForUpdatesChecking())
GetUpdates();
GetUpdates(true);
mTimer.StartOnce(std::chrono::duration_cast<std::chrono::milliseconds>(
updatesCheckInterval)

View File

@ -36,7 +36,7 @@ public:
static UpdateManager& GetInstance();
static void Start();
void GetUpdates();
void GetUpdates(bool ignoreNetworkErrors);
VersionPatch GetVersionPatch() const;