Browse Source

Merge pull request #2025 from zarechnyy/fix/disk-storage-config

Make ‘cachePathBlock’ public
Wei Wang 3 years ago
parent
commit
57fea0db13
1 changed files with 7 additions and 5 deletions
  1. 7 5
      Sources/Cache/DiskStorage.swift

+ 7 - 5
Sources/Cache/DiskStorage.swift

@@ -457,16 +457,18 @@ extension DiskStorage {
         /// If set to `true`, image extension will be extracted from original file name and append to
         /// the hased file name and used as the cache key on disk.
         public var autoExtAfterHashedFileName = false
+        
+        /// Closure that takes in initial directory path and generates
+        /// the final disk cache path. You can use it to fully customize your cache path.
+        public var cachePathBlock: ((_ directory: URL, _ cacheName: String) -> URL)! = {
+            (directory, cacheName) in
+            return directory.appendingPathComponent(cacheName, isDirectory: true)
+        }
 
         let name: String
         let fileManager: FileManager
         let directory: URL?
 
-        var cachePathBlock: ((_ directory: URL, _ cacheName: String) -> URL)! = {
-            (directory, cacheName) in
-            return directory.appendingPathComponent(cacheName, isDirectory: true)
-        }
-
         /// Creates a config value based on given parameters.
         ///
         /// - Parameters: