From 33fa07ec1a47c7a570e46dfc9a47ea0ce35d311c Mon Sep 17 00:00:00 2001 From: Chris Araman Date: Wed, 14 Apr 2021 17:37:17 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=A3=20Use=20an=20ephemeral=20session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MasKit/Network/NetworkManager.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MasKit/Network/NetworkManager.swift b/MasKit/Network/NetworkManager.swift index b6f4e16..a76612f 100644 --- a/MasKit/Network/NetworkManager.swift +++ b/MasKit/Network/NetworkManager.swift @@ -19,8 +19,14 @@ public class NetworkManager { /// Designated initializer /// /// - Parameter session: A networking session. - public init(session: NetworkSession = URLSession.shared) { + public init(session: NetworkSession = URLSession(configuration: .ephemeral)) { 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.