Make serviceURL an external static var

This commit is contained in:
Davide De Rosa 2018-11-01 13:31:08 +01:00
parent 36995e089b
commit 964a4d701b
1 changed files with 7 additions and 5 deletions

View File

@ -35,9 +35,11 @@ class TransientStore {
static let shared = TransientStore()
let service: ConnectionService
private static var serviceURL: URL {
return FileManager.default.userURL(for: .documentDirectory, appending: AppConstants.Store.serviceFilename)
}
private let serviceURL = FileManager.default.userURL(for: .documentDirectory, appending: AppConstants.Store.serviceFilename)
let service: ConnectionService
var didHandleSubreddit: Bool {
get {
@ -51,9 +53,9 @@ class TransientStore {
private init() {
let cfg = AppConstants.VPN.baseConfiguration()
do {
ConnectionService.migrateJSON(at: serviceURL, to: serviceURL)
ConnectionService.migrateJSON(at: TransientStore.serviceURL, to: TransientStore.serviceURL)
let data = try Data(contentsOf: serviceURL)
let data = try Data(contentsOf: TransientStore.serviceURL)
if let content = String(data: data, encoding: .utf8) {
log.verbose("Service JSON:")
log.verbose(content)
@ -76,7 +78,7 @@ class TransientStore {
}
func serialize() {
try? JSONEncoder().encode(service).write(to: serviceURL)
try? JSONEncoder().encode(service).write(to: TransientStore.serviceURL)
try? service.saveProfiles()
}
}