onevcat 2 лет назад
Родитель
Сommit
c4a7768d78

+ 0 - 5
Sources/General/ImageSource/ImageDataProvider.swift

@@ -103,9 +103,6 @@ public struct LocalFileImageDataProvider: ImageDataProvider {
         }
     }
     
-    #if swift(>=5.5)
-    #if canImport(_Concurrency)
-    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
     public var data: Data {
         get async throws {
             try await withCheckedThrowingContinuation { continuation in
@@ -120,8 +117,6 @@ public struct LocalFileImageDataProvider: ImageDataProvider {
             }
         }
     }
-    #endif
-    #endif
 
     /// The URL of the local file on the disk.
     public var contentURL: URL? {

+ 3 - 0
Sources/General/ImageSource/Source.swift

@@ -42,7 +42,10 @@ public enum Source {
         /// The underlying value type of source identifier.
         public typealias Value = UInt
         static private(set) var current: Value = 0
+        
+        // Not thread safe. Expected to be always called on the main thread.
         static func next() -> Value {
+            assert(Thread.isMainThread, "The identifier `next()` should only be called on main thread.")
             current += 1
             return current
         }

+ 2 - 12
Tests/KingfisherTests/ImageDataProviderTests.swift

@@ -51,9 +51,6 @@ class ImageDataProviderTests: XCTestCase {
         waitForExpectations(timeout: 1, handler: nil)
     }
     
-    #if swift(>=5.5)
-    #if canImport(_Concurrency)
-    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
     func testLocalFileImageDataProviderAsync() async {
         let fm = FileManager.default
         let document = try! fm.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
@@ -70,9 +67,7 @@ class ImageDataProviderTests: XCTestCase {
         XCTAssertEqual(value, testImageData)
         try! fm.removeItem(at: fileURL)
     }
-    #endif
-    #endif
-    
+
     func testLocalFileImageDataProviderMainQueue() {
         let fm = FileManager.default
         let document = try! fm.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
@@ -92,10 +87,7 @@ class ImageDataProviderTests: XCTestCase {
 
         XCTAssertTrue(called)
     }
-    
-    #if swift(>=5.5)
-    #if canImport(_Concurrency)
-    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
+
     func testLocalFileImageDataProviderMainQueueAsync() async {
         let fm = FileManager.default
         let document = try! fm.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
@@ -114,8 +106,6 @@ class ImageDataProviderTests: XCTestCase {
 
         XCTAssertTrue(called)
     }
-    #endif
-    #endif
     
     func testLocalFileCacheKey() {
         let url1 = URL(string: "file:///Users/onevcat/Library/Developer/CoreSimulator/Devices/ABC/data/Containers/Bundle/Application/DEF/Kingfisher-Demo.app/images/kingfisher-1.jpg")!