summaryrefslogtreecommitdiff
path: root/src/serverinfo.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-08-26 01:31:56 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-08-26 01:31:56 -0400
commit896d80d02ccef746ba6598534ce444da2755ae04 (patch)
tree90f7a878d11ecf0436d79a40b47b222d3ed4dfe0 /src/serverinfo.cpp
parentaff3ee8fcf427c9ff8c554a179222eabec3a95e2 (diff)
server settings converted to array instead of byte array map
moved cleanup to ServerList
Diffstat (limited to 'src/serverinfo.cpp')
-rw-r--r--src/serverinfo.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/serverinfo.cpp b/src/serverinfo.cpp
index 70cdec6d..16e65f52 100644
--- a/src/serverinfo.cpp
+++ b/src/serverinfo.cpp
@@ -1,4 +1,7 @@
#include "serverinfo.h"
+#include "log.h"
+
+using namespace MOBase;
ServerInfo::ServerInfo()
: ServerInfo({}, false, {}, 0, 0, 0.0)
@@ -100,3 +103,22 @@ ServerList::container ServerList::getPreferred() const
return v;
}
+
+void ServerList::cleanup()
+{
+ QDate now = QDate::currentDate();
+
+ for (auto itor=m_servers.begin(); itor!=m_servers.end(); ) {
+ const QDate lastSeen = itor->lastSeen();
+
+ if (lastSeen.daysTo(now) > 30) {
+ log::debug(
+ "removing server {} since it hasn't been available for downloads "
+ "in over a month", itor->name());
+
+ itor = m_servers.erase(itor);
+ } else {
+ ++itor;
+ }
+ }
+}