Skip to content

Commit

Permalink
Fix access control
Browse files Browse the repository at this point in the history
  • Loading branch information
cozzin committed Apr 24, 2023
1 parent 50ccc78 commit c577759
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/Cache/Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Cache<Value>: CacheStorage where Value: Codable {

private let disk: DiskCache<Value>

init(memory: MemoryCache<Value> = .init(countLimit: 300), disk: DiskCache<Value> = .init()) {
public init(memory: MemoryCache<Value> = .init(countLimit: 300), disk: DiskCache<Value> = .init()) {
self.memory = memory
self.disk = disk
}
Expand Down
12 changes: 7 additions & 5 deletions Sources/Cache/Disk/DefaultFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@

import Foundation

struct DefaultFileManager: DiskCacheFileManagable {
public struct DefaultFileManager: DiskCacheFileManagable {

func assureDirectoryExists(filePathURL: URL) throws {
public init() { }

public func assureDirectoryExists(filePathURL: URL) throws {
if FileManager.default.fileExists(atPath: filePathURL.path) == false {
try FileManager.default.createDirectory(at: filePathURL.deletingLastPathComponent(), withIntermediateDirectories: true)
}
}

func filePathURL(forKey key: String) throws -> URL {
public func filePathURL(forKey key: String) throws -> URL {
try FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent(key)
}

func write(_ data: Data, to url: URL) throws {
public func write(_ data: Data, to url: URL) throws {
try data.write(to: url)
}

func data(of url: URL) throws -> Data {
public func data(of url: URL) throws -> Data {
try Data(contentsOf: url)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Cache/Disk/DiskCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct DiskCache<Value>: CacheStorage where Value: Codable {

private let fileManager: DiskCacheFileManagable

init(fileManager: DiskCacheFileManagable = DefaultFileManager()) {
public init(fileManager: DiskCacheFileManagable = DefaultFileManager()) {
self.fileManager = fileManager
}

Expand Down

0 comments on commit c577759

Please sign in to comment.