Merge pull request #345 from mas-cli/cache

🪣 Use an ephemeral session
This commit is contained in:
Chris Araman 2021-04-14 17:47:01 -07:00 committed by GitHub
commit 99bd7533b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,8 +19,14 @@ public class NetworkManager {
/// Designated initializer /// Designated initializer
/// ///
/// - Parameter session: A networking session. /// - Parameter session: A networking session.
public init(session: NetworkSession = URLSession.shared) { public init(session: NetworkSession = URLSession(configuration: .ephemeral)) {
self.session = session self.session = session
// Older releases allowed URLSession to write a cache. We clean it up here.
do {
let url = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("Library/Caches/com.mphys.mas-cli")
try FileManager.default.removeItem(at: url)
} catch {}
} }
/// Loads data asynchronously. /// Loads data asynchronously.