|
|
@@ -196,11 +196,18 @@ public enum DiskStorage {
|
|
|
}
|
|
|
|
|
|
func cacheFileName(forKey key: String) -> String {
|
|
|
- let hashedKey = key.kf.md5
|
|
|
- if let ext = config.pathExtension {
|
|
|
- return "\(hashedKey).\(ext)"
|
|
|
+ if self.config.useEncryptionForCacheFileName {
|
|
|
+ let hashedKey = key.kf.md5
|
|
|
+ if let ext = config.pathExtension {
|
|
|
+ return "\(hashedKey).\(ext)"
|
|
|
+ }
|
|
|
+ return hashedKey
|
|
|
+ } else {
|
|
|
+ if let ext = config.pathExtension {
|
|
|
+ return "\(key).\(ext)"
|
|
|
+ }
|
|
|
+ return key
|
|
|
}
|
|
|
- return hashedKey
|
|
|
}
|
|
|
|
|
|
func allFileURLs(for propertyKeys: [URLResourceKey]) throws -> [URL] {
|
|
|
@@ -310,6 +317,9 @@ extension DiskStorage {
|
|
|
/// Default is `nil`, means that the cache file does not contain a file extension.
|
|
|
public var pathExtension: String? = nil
|
|
|
|
|
|
+ /// Default is `true`, means that md5 encryption will be used for creation the cache file name.
|
|
|
+ public var useEncryptionForCacheFileName: Bool = true
|
|
|
+
|
|
|
let name: String
|
|
|
let fileManager: FileManager
|
|
|
let directory: URL?
|