diff --git a/Orbot/SettingsViewController.swift b/Orbot/SettingsViewController.swift index ad3a65f..6919ae6 100644 --- a/Orbot/SettingsViewController.swift +++ b/Orbot/SettingsViewController.swift @@ -179,7 +179,24 @@ class SettingsViewController: BaseFormViewController { } }) - +++ LabelRow() { + +++ Section(L10n.maintenance) + <<< ButtonRow("clearCache") { + $0.title = L10n.clearTorCache + $0.disabled = Condition.function(["clearCache"], { _ in + VpnManager.shared.isConnected + }) + } + .onCellSelection({ _, row in + if row.isDisabled { + return + } + + TorHelpers.clearCache() + + AlertHelper.present(self, message: L10n.cleared, title: L10n.clearTorCache) + }) + + <<< LabelRow() { $0.title = L10n.version $0.cellStyle = .default @@ -189,6 +206,10 @@ class SettingsViewController: BaseFormViewController { textLabel.font = textLabel.font.withSize(textLabel.font.pointSize * 0.75) } } + + NotificationCenter.default.addObserver(forName: .vpnStatusChanged, object: nil, queue: .main) { [weak self] _ in + self?.form.rowBy(tag: "clearCache")?.evaluateDisabled() + } } override func viewDidDisappear(_ animated: Bool) { diff --git a/Shared/TorManager.swift b/Shared/TorManager.swift index 2f9cac9..34331f5 100644 --- a/Shared/TorManager.swift +++ b/Shared/TorManager.swift @@ -125,13 +125,6 @@ class TorManager { return #else if !torRunning { - // When running on iOS, always delete the cache before starting. - // Something with the network happened and now Tor almost always uses too much - // memory when starting with cached microdescriptors. - #if os(iOS) - TorHelpers.clearCache() - #endif - torConf = getTorConf() // if let debug = torConf?.compile().joined(separator: ", ") {