Clears image cache with “Clear Cache…” option in Settings

Also increases image cache size to 512MB.
This commit is contained in:
Riley Testut
2023-12-07 16:58:39 -06:00
parent 0d9de4814d
commit 6a37957121
2 changed files with 40 additions and 0 deletions

View File

@@ -9,6 +9,8 @@
import Foundation
import AltStoreCore
import Nuke
struct BatchError: ALTLocalizedError
{
enum Code: Int, ALTErrorCode
@@ -54,6 +56,8 @@ class ClearAppCacheOperation: ResultOperation<Void>
{
super.main()
self.clearNukeCache()
var allErrors = [Error]()
self.clearTemporaryDirectory { result in
@@ -88,6 +92,12 @@ class ClearAppCacheOperation: ResultOperation<Void>
private extension ClearAppCacheOperation
{
func clearNukeCache()
{
guard let dataCache = ImagePipeline.shared.configuration.dataCache as? DataCache else { return }
dataCache.removeAll()
}
func clearTemporaryDirectory(completion: @escaping (Result<Void, Error>) -> Void)
{
let intent = NSFileAccessIntent.writingIntent(with: FileManager.default.temporaryDirectory, options: [.forDeleting])