Эх сурвалжийг харах

improvements

Signed-off-by: Marino Faggiana <8616947+marinofaggiana@users.noreply.github.com>
Marino Faggiana 1 жил өмнө
parent
commit
6a560e3d80

+ 7 - 1
iOSClient/Media/NCMediaCache.swift

@@ -32,8 +32,11 @@ import NextcloudKit
         return instance
         return instance
     }()
     }()
 
 
+    let limit: Int = 2000
     private typealias ThumbnailLRUCache = LRUCache<String, UIImage>
     private typealias ThumbnailLRUCache = LRUCache<String, UIImage>
-    private let cache: ThumbnailLRUCache = ThumbnailLRUCache(countLimit: 2000)
+    private lazy var cache: ThumbnailLRUCache = {
+        return ThumbnailLRUCache(countLimit: limit)
+    }()
 
 
     func createCache(account: String) {
     func createCache(account: String) {
 
 
@@ -76,7 +79,10 @@ import NextcloudKit
 
 
         // Insert in cache
         // Insert in cache
         cache.removeAllValues()
         cache.removeAllValues()
+        var counter: Int = 0
         for file in files {
         for file in files {
+            counter += 1
+            if counter > limit { break }
             autoreleasepool {
             autoreleasepool {
                 if let image = UIImage(contentsOfFile: file.path.path) {
                 if let image = UIImage(contentsOfFile: file.path.path) {
                     cache.setValue(image, forKey: file.ocId)
                     cache.setValue(image, forKey: file.ocId)