diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-26 01:31:56 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-08-26 01:31:56 -0400 |
| commit | 896d80d02ccef746ba6598534ce444da2755ae04 (patch) | |
| tree | 90f7a878d11ecf0436d79a40b47b222d3ed4dfe0 /src/serverinfo.cpp | |
| parent | aff3ee8fcf427c9ff8c554a179222eabec3a95e2 (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.cpp | 22 |
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;
+ }
+ }
+}
|
