Skip to content

Commit fe15b7c

Browse files
committed
DiskStorage file URL handling improvements
1 parent 7bad9f4 commit fe15b7c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Source/Shared/Storage/DiskStorage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extension DiskStorage: StorageAware {
6464

6565
public func entry(forKey key: Key) throws -> Entry<Value> {
6666
let filePath = makeFilePath(for: key)
67-
let data = try Data(contentsOf: URL(fileURLWithPath: filePath))
67+
let data = try Data(contentsOf: URL(fileURLWithPath: filePath, isDirectory: false))
6868
let attributes = try fileManager.attributesOfItem(atPath: filePath)
6969
let object = try transformer.fromData(data)
7070

@@ -99,7 +99,7 @@ extension DiskStorage: StorageAware {
9999
}
100100

101101
public func removeExpiredObjects() throws {
102-
let storageURL = URL(fileURLWithPath: path)
102+
let storageURL = URL(fileURLWithPath: path, isDirectory: true)
103103
let resourceKeys: [URLResourceKey] = [
104104
.isDirectoryKey,
105105
.contentModificationDateKey,
@@ -167,7 +167,7 @@ extension DiskStorage {
167167
*/
168168
func makeFileName(for key: Key) -> String {
169169
if let key = key as? String {
170-
let fileExtension = URL(fileURLWithPath: key).pathExtension
170+
let fileExtension = (key as NSString).pathExtension
171171
let fileName = MD5(key)
172172

173173
switch fileExtension.isEmpty {

0 commit comments

Comments
 (0)