Compare commits
No commits in common. "cccde29e6c591c62d663b8f16e2e847a0117d809" and "d224f47b8c2b37ed83c05edc6e2edea103c625e0" have entirely different histories.
cccde29e6c
...
d224f47b8c
|
@ -21,7 +21,7 @@ class DiskCache<T> {
|
||||||
let defaultExpiry: CacheExpiry
|
let defaultExpiry: CacheExpiry
|
||||||
let transformer: DiskCacheTransformer<T>
|
let transformer: DiskCacheTransformer<T>
|
||||||
|
|
||||||
private var fileStates = MultiThreadDictionary<String, FileState>()
|
private var fileStates = [String: FileState]()
|
||||||
|
|
||||||
init(name: String, defaultExpiry: CacheExpiry, transformer: DiskCacheTransformer<T>, fileManager: FileManager = .default) throws {
|
init(name: String, defaultExpiry: CacheExpiry, transformer: DiskCacheTransformer<T>, fileManager: FileManager = .default) throws {
|
||||||
self.defaultExpiry = defaultExpiry
|
self.defaultExpiry = defaultExpiry
|
||||||
|
@ -117,9 +117,7 @@ class DiskCache<T> {
|
||||||
func removeAll() throws {
|
func removeAll() throws {
|
||||||
try fileManager.removeItem(atPath: path)
|
try fileManager.removeItem(atPath: path)
|
||||||
try createDirectory()
|
try createDirectory()
|
||||||
fileStates.withLock { dict in
|
fileStates.removeAll()
|
||||||
dict.removeAll()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,13 @@ class MultiThreadDictionary<Key: Hashable & Sendable, Value: Sendable> {
|
||||||
private let lock: LockHolder<[AnyHashable: Any]>
|
private let lock: LockHolder<[AnyHashable: Any]>
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.lock = LockHolder(initialState: [:])
|
if #available(iOS 16.0, *) {
|
||||||
|
let lock = OSAllocatedUnfairLock(initialState: [:])
|
||||||
|
self.lock = LockHolder(withLock: lock.withLock(_:))
|
||||||
|
} else {
|
||||||
|
let lock = UnfairLock(initialState: [:])
|
||||||
|
self.lock = LockHolder(withLock: lock.withLock(_:))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subscript(key: Key) -> Value? {
|
subscript(key: Key) -> Value? {
|
||||||
|
@ -60,16 +66,6 @@ class MultiThreadDictionary<Key: Hashable & Sendable, Value: Sendable> {
|
||||||
// see #178
|
// see #178
|
||||||
fileprivate struct LockHolder<State> {
|
fileprivate struct LockHolder<State> {
|
||||||
let withLock: (_ body: @Sendable (inout State) throws -> any Sendable) throws -> any Sendable
|
let withLock: (_ body: @Sendable (inout State) throws -> any Sendable) throws -> any Sendable
|
||||||
|
|
||||||
init(initialState: State) {
|
|
||||||
if #available(iOS 16.0, *) {
|
|
||||||
let lock = OSAllocatedUnfairLock(initialState: initialState)
|
|
||||||
self.withLock = lock.withLock(_:)
|
|
||||||
} else {
|
|
||||||
let lock = UnfairLock(initialState: initialState)
|
|
||||||
self.withLock = lock.withLock(_:)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace this only with OSAllocatedUnfairLock
|
// TODO: replace this only with OSAllocatedUnfairLock
|
||||||
|
|
|
@ -142,7 +142,6 @@ class IssueReporterViewController: UIViewController {
|
||||||
let url = dir.appendingPathComponent(reportFilename)
|
let url = dir.appendingPathComponent(reportFilename)
|
||||||
try! reportText.data(using: .utf8)!.write(to: url)
|
try! reportText.data(using: .utf8)!.write(to: url)
|
||||||
let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
||||||
activityController.popoverPresentationController?.sourceView = sendReportButton
|
|
||||||
present(activityController, animated: true)
|
present(activityController, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +154,7 @@ class IssueReporterViewController: UIViewController {
|
||||||
extension IssueReporterViewController: MFMailComposeViewControllerDelegate {
|
extension IssueReporterViewController: MFMailComposeViewControllerDelegate {
|
||||||
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||||
controller.dismiss(animated: true) {
|
controller.dismiss(animated: true) {
|
||||||
if result == .cancelled {
|
self.dismiss()
|
||||||
// don't dismiss ourself, to allowe the user to send the report a different way
|
|
||||||
} else {
|
|
||||||
self.dismiss()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue