mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Cache usage experiment
This commit is contained in:
parent
e543bf1e2e
commit
575fa5264d
@ -3,9 +3,9 @@ import Foundation
|
||||
public func fileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? {
|
||||
if useTotalFileAllocatedSize {
|
||||
let url = URL(fileURLWithPath: path)
|
||||
if let values = (try? url.resourceValues(forKeys: Set([.isRegularFileKey, .totalFileAllocatedSizeKey]))) {
|
||||
if let values = (try? url.resourceValues(forKeys: Set([.isRegularFileKey, .fileAllocatedSizeKey]))) {
|
||||
if values.isRegularFile ?? false {
|
||||
if let fileSize = values.totalFileAllocatedSize {
|
||||
if let fileSize = values.fileAllocatedSize {
|
||||
return Int64(fileSize)
|
||||
}
|
||||
}
|
||||
|
@ -582,6 +582,14 @@ func _internal_reindexCacheInBackground(account: Account, lowImpact: Bool) -> Si
|
||||
processResource(mediaMessages, representation.resource, MediaResourceUserContentType(file: file))
|
||||
}
|
||||
processResource(mediaMessages, file.resource, MediaResourceUserContentType(file: file))
|
||||
for alternativeRepresentation in file.alternativeRepresentations {
|
||||
if let alternativeRepresentation = alternativeRepresentation as? TelegramMediaFile {
|
||||
for representation in alternativeRepresentation.previewRepresentations {
|
||||
processResource(mediaMessages, representation.resource, MediaResourceUserContentType(file: file))
|
||||
}
|
||||
processResource(mediaMessages, alternativeRepresentation.resource, MediaResourceUserContentType(file: file))
|
||||
}
|
||||
}
|
||||
} else if let webpage = media as? TelegramMediaWebpage {
|
||||
if case let .Loaded(content) = webpage.content {
|
||||
if let image = content.image {
|
||||
|
@ -1492,6 +1492,12 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
let timestamp = Int(CFAbsoluteTimeGetCurrent())
|
||||
let minReindexTimestamp = timestamp - 2 * 24 * 60 * 60
|
||||
if let indexTimestamp = UserDefaults.standard.object(forKey: "TelegramCacheIndexTimestamp") as? NSNumber, indexTimestamp.intValue >= minReindexTimestamp {
|
||||
#if DEBUG && false
|
||||
Logger.shared.log("App \(self.episodeId)", "Executing low-impact cache reindex in foreground")
|
||||
let _ = self.runCacheReindexTasks(lowImpact: true, completion: {
|
||||
Logger.shared.log("App \(self.episodeId)", "Executing low-impact cache reindex in foreground — done1")
|
||||
})
|
||||
#endif
|
||||
} else {
|
||||
UserDefaults.standard.set(timestamp as NSNumber, forKey: "TelegramCacheIndexTimestamp")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user