Auto-delete logs finished + custom App-to-VPN messages

This commit is contained in:
relikd
2020-06-28 23:55:08 +02:00
parent 08483711e2
commit 6dcc2086e6
7 changed files with 142 additions and 18 deletions

View File

@@ -15,7 +15,7 @@ struct TheGreatDestroyer {
}
}
/// Fired when user taps on Settings -> Delete All Logs
/// Fired when user taps on Settings -> "Delete All Logs"
static func deleteAllLogs() {
sync.pause()
DispatchQueue.global().async {
@@ -26,4 +26,18 @@ struct TheGreatDestroyer {
} catch {}
}
}
/// Fired when user changes Settings -> "Auto-delete logs" and every time the App enters foreground
static func deleteLogs(olderThan days: Int) {
guard days > 0 else { return }
sync.pause()
DispatchQueue.global().async {
defer { sync.continue() }
QLog.Info("Auto-delete logs")
guard let success = try? AppDB?.dnsLogsDeleteOlderThan(days: days), success else {
return // nothing changed
}
sync.needsReloadDB()
}
}
}