From 896d80d02ccef746ba6598534ce444da2755ae04 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 26 Aug 2019 01:31:56 -0400 Subject: server settings converted to array instead of byte array map moved cleanup to ServerList --- src/settings.cpp | 94 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 32 deletions(-) (limited to 'src/settings.cpp') diff --git a/src/settings.cpp b/src/settings.cpp index c57530e4..3a7bda75 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -869,6 +869,50 @@ void Settings::setDownloadSpeed(const QString &serverName, int bytesPerSecond) ServerList Settings::getServers() const { + // servers used to be a map of byte arrays until 2.2.1, it's now an array of + // individual values instead + // + // so post 2.2.1, only one key is returned: "size", the size of the arrays; + // in 2.2.1, one key per server is returned + + // getting the keys + m_Settings.beginGroup("Servers"); + const auto keys = m_Settings.childKeys(); + m_Settings.endGroup(); + + if (!keys.empty() && keys[0] != "size") { + // old format + return getServersFromOldMap(); + } + + + ServerList list; + + const int size = m_Settings.beginReadArray("Servers"); + + for (int i=0; i 30) { - log::debug("removing server {} since it hasn't been available for downloads in over a month", key); - m_Settings.remove(key); - } + ++i; } - m_Settings.endGroup(); - - m_Settings.sync(); + m_Settings.endArray(); } void Settings::addBlacklistPlugin(const QString &fileName) -- cgit v1.3.1