onevcat 7 лет назад
Родитель
Сommit
6021248897
2 измененных файлов с 3 добавлено и 13 удалено
  1. 1 9
      Sources/Cache/DiskStorage.swift
  2. 2 4
      Sources/Networking/SessionDelegate.swift

+ 1 - 9
Sources/Cache/DiskStorage.swift

@@ -112,7 +112,6 @@ public enum DiskStorage {
                 // The estimated expiration date.
                 .modificationDate: (expiration ?? config.expiration).estimatedExpirationSinceNow.fileAttributeDate
             ]
-            print("Set: \(attributes)")
             config.fileManager.createFile(atPath: fileURL.path, contents: data, attributes: attributes)
         }
 
@@ -401,14 +400,7 @@ extension DiskStorage {
                 .modificationDate: originalExpiration.estimatedExpirationSinceNow.fileAttributeDate
             ]
 
-            do {
-                if fileManager.fileExists(atPath: url.path) {
-                    try fileManager.setAttributes(attributes, ofItemAtPath: url.path)
-                }
-            } catch {
-                assertionFailure("[Kingfisher] Updating cache attributes fails at path: \(url), " +
-                    "target attributes: \(attributes). Error: \(error)")
-            }
+            try? fileManager.setAttributes(attributes, ofItemAtPath: url.path)
         }
     }
 }

+ 2 - 4
Sources/Networking/SessionDelegate.swift

@@ -88,11 +88,9 @@ class SessionDelegate: NSObject {
         guard let url = task.originalRequest?.url else {
             return
         }
-        if acquireLock {
-            lock.lock()
-            defer { lock.unlock() }
-        }
+        if acquireLock { lock.lock() }
         tasks[url] = nil
+        if acquireLock { lock.unlock() }
     }
 
     func task(for task: URLSessionTask) -> SessionDataTask? {