Skip to content

Commit

Permalink
Remove automatic cache clearing before start in iOS, since we now hav…
Browse files Browse the repository at this point in the history
…e a patch to Tor which makes this superfluous. Now starts with a warm cache will be way faster again.
  • Loading branch information
tladesignz committed Aug 30, 2023
1 parent 3487fd3 commit dd526e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
23 changes: 22 additions & 1 deletion Orbot/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions Shared/TorManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: ", ") {
Expand Down

0 comments on commit dd526e4

Please sign in to comment.