Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoExtAfterHashedFileName breaks caching for some URLs #2301

Open
3 tasks done
Ceylo opened this issue Oct 9, 2024 · 0 comments
Open
3 tasks done

autoExtAfterHashedFileName breaks caching for some URLs #2301

Ceylo opened this issue Oct 9, 2024 · 0 comments

Comments

@Ceylo
Copy link

Ceylo commented Oct 9, 2024

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

What

I wanted to use DiskStorage.config.autoExtAfterHashedFileName in order to have a file ready for usage as url in

try await PHPhotoLibrary.shared().performChanges { @Sendable in
    let request = PHAssetCreationRequest.forAsset()
    request.addResource(with: .photo, fileURL: url, options: nil)
}

but the autoExtAfterHashedFileName setting just looks to fully break caching in my case. It does happen with some URLs only. Without this option, I have to add a copy of the file after disk cache is ready (because PH API wants a file path with extension).

Reproduce

Note: removing the precondition allows the image to display, so it's not a matter of bad URL.

import SwiftUI
import Kingfisher

@main
struct autoExtAfterHashedFileNameApp: App {
    init() {
        ImageCache.default.diskStorage.config.autoExtAfterHashedFileName = true
    }
    
    // Works
//    let url = URL(string: "https://user-images.githubusercontent.com/1812216/106253726-271ed000-6218-11eb-98e0-c9c681925770.png")!
    // Doesn't work
    let url = URL(string: "https://t.furaffinity.net/[email protected]")!
    
    var body: some Scene {
        WindowGroup {
            KFImage(url)
                .waitForCache()
                .onSuccess { result in
                    precondition(result.cacheType != .none)
                }
        }
    }
}

Other Comment

[Add anything else here]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant