add: clear media cache

This commit is contained in:
ihugo 2021-04-13 13:52:46 +08:00
parent 16fc1a85bd
commit 262eeeccba
1 changed files with 15 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import Combine
import ActiveLabel import ActiveLabel
import CoreData import CoreData
import CoreDataStack import CoreDataStack
import AlamofireImage
import Kingfisher
// iTODO: when to ask permission to Use Notifications // iTODO: when to ask permission to Use Notifications
@ -309,8 +311,19 @@ extension SettingsViewController: UITableViewDelegate {
) )
} }
// iTODO: clear media cache // clear media cache
if indexPath.section == 3, indexPath.row == 0 {
// clean image cache for AlamofireImage
let diskBytes = ImageDownloader.defaultURLCache().currentDiskUsage
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: diskBytes %d", ((#file as NSString).lastPathComponent), #line, #function, diskBytes)
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: clean image cache", ((#file as NSString).lastPathComponent), #line, #function)
ImageDownloader.defaultURLCache().removeAllCachedResponses()
let cleanedDiskBytes = ImageDownloader.defaultURLCache().currentDiskUsage
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: diskBytes %d", ((#file as NSString).lastPathComponent), #line, #function, cleanedDiskBytes)
// clean Kingfisher Cache
KingfisherManager.shared.cache.clearDiskCache()
}
// logout // logout
if indexPath.section == 3, indexPath.row == 1 { if indexPath.section == 3, indexPath.row == 1 {