Explorar el Código

Make ‘cachePathBlock’ public

Yaroslav Zarichnyi hace 3 años
padre
commit
1e5cc543e6
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  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
         /// 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.
         /// the hased file name and used as the cache key on disk.
         public var autoExtAfterHashedFileName = false
         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 name: String
         let fileManager: FileManager
         let fileManager: FileManager
         let directory: URL?
         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.
         /// Creates a config value based on given parameters.
         ///
         ///
         /// - Parameters:
         /// - Parameters: