🪣 Use an ephemeral session

This commit is contained in:
Chris Araman 2021-04-14 17:37:17 -07:00
parent 7a3a519e86
commit 33fa07ec1a
No known key found for this signature in database
GPG key ID: BB4499D9E11B61E0

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.