Update Kingfisher to 8.3.1
Changelog-Changed: Updated image cache for better stability Closes: https://github.com/damus-io/damus/issues/2899 Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -6862,7 +6862,7 @@
|
|||||||
repositoryURL = "https://github.com/onevcat/Kingfisher";
|
repositoryURL = "https://github.com/onevcat/Kingfisher";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = upToNextMajorVersion;
|
kind = upToNextMajorVersion;
|
||||||
minimumVersion = 7.0.0;
|
minimumVersion = 8.3.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
4C27C9302A64766F007DBC75 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
|
4C27C9302A64766F007DBC75 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
|
||||||
|
|||||||
@@ -49,8 +49,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/onevcat/Kingfisher",
|
"location" : "https://github.com/onevcat/Kingfisher",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "415b1d97fb38bda1e5a6b2dde63354720832110b",
|
"revision" : "4c6b067f96953ee19526e49e4189403a2be21fb3",
|
||||||
"version" : "7.6.1"
|
"version" : "8.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ func preload_image(url: URL) {
|
|||||||
|
|
||||||
//print("Preloading image \(url.absoluteString)")
|
//print("Preloading image \(url.absoluteString)")
|
||||||
|
|
||||||
KingfisherManager.shared.retrieveImage(with: Kingfisher.ImageResource(downloadURL: url)) { val in
|
KingfisherManager.shared.retrieveImage(with: Kingfisher.KF.ImageResource(downloadURL: url)) { val in
|
||||||
//print("Preloaded image \(url.absoluteString)")
|
//print("Preloaded image \(url.absoluteString)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ extension KFOptionSetter {
|
|||||||
|
|
||||||
func onFailure(fallbackUrl: URL?, cacheKey: String?) -> Self {
|
func onFailure(fallbackUrl: URL?, cacheKey: String?) -> Self {
|
||||||
guard let url = fallbackUrl, let key = cacheKey else { return self }
|
guard let url = fallbackUrl, let key = cacheKey else { return self }
|
||||||
let imageResource = Kingfisher.ImageResource(downloadURL: url, cacheKey: key)
|
let imageResource = Kingfisher.KF.ImageResource(downloadURL: url, cacheKey: key)
|
||||||
let source = imageResource.convertToSource()
|
let source = imageResource.convertToSource()
|
||||||
options.alternativeSources = [source]
|
options.alternativeSources = [source]
|
||||||
|
|
||||||
@@ -159,20 +159,25 @@ struct CustomCacheSerializer: CacheSerializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomSessionDelegate: SessionDelegate {
|
class CustomSessionDelegate: SessionDelegate, @unchecked Sendable {
|
||||||
override func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
|
override func urlSession(
|
||||||
|
_ session: URLSession,
|
||||||
|
dataTask: URLSessionDataTask,
|
||||||
|
didReceive response: URLResponse
|
||||||
|
) async -> URLSession.ResponseDisposition {
|
||||||
let contentLength = response.expectedContentLength
|
let contentLength = response.expectedContentLength
|
||||||
|
|
||||||
// Content-Length header is optional (-1 when missing)
|
// Content-Length header is optional (-1 when missing)
|
||||||
if (contentLength != -1 && contentLength > MAX_FILE_SIZE) {
|
if (contentLength != -1 && contentLength > MAX_FILE_SIZE) {
|
||||||
return super.urlSession(session, dataTask: dataTask, didReceive: URLResponse(), completionHandler: completionHandler)
|
return await super.urlSession(session, dataTask: dataTask, didReceive: URLResponse())
|
||||||
}
|
}
|
||||||
|
|
||||||
super.urlSession(session, dataTask: dataTask, didReceive: response, completionHandler: completionHandler)
|
return await super.urlSession(session, dataTask: dataTask, didReceive: response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomImageDownloader: ImageDownloader {
|
|
||||||
|
class CustomImageDownloader: ImageDownloader, @unchecked Sendable {
|
||||||
|
|
||||||
static let shared = CustomImageDownloader(name: "shared")
|
static let shared = CustomImageDownloader(name: "shared")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user