Skip to content

Commit

Permalink
Merge pull request hyperoslo#283 from shadowfacts/url-initializer-tweak
Browse files Browse the repository at this point in the history
DiskStorage file URL handling improvements
  • Loading branch information
3lvis authored Jan 30, 2021
2 parents 7bad9f4 + fe15b7c commit 520b1af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Shared/Storage/DiskStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension DiskStorage: StorageAware {

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

Expand Down Expand Up @@ -99,7 +99,7 @@ extension DiskStorage: StorageAware {
}

public func removeExpiredObjects() throws {
let storageURL = URL(fileURLWithPath: path)
let storageURL = URL(fileURLWithPath: path, isDirectory: true)
let resourceKeys: [URLResourceKey] = [
.isDirectoryKey,
.contentModificationDateKey,
Expand Down Expand Up @@ -167,7 +167,7 @@ extension DiskStorage {
*/
func makeFileName(for key: Key) -> String {
if let key = key as? String {
let fileExtension = URL(fileURLWithPath: key).pathExtension
let fileExtension = (key as NSString).pathExtension
let fileName = MD5(key)

switch fileExtension.isEmpty {
Expand Down

0 comments on commit 520b1af

Please sign in to comment.