Make serviceURL an external static var
This commit is contained in:
parent
36995e089b
commit
964a4d701b
|
@ -35,9 +35,11 @@ class TransientStore {
|
||||||
|
|
||||||
static let shared = 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 {
|
var didHandleSubreddit: Bool {
|
||||||
get {
|
get {
|
||||||
|
@ -51,9 +53,9 @@ class TransientStore {
|
||||||
private init() {
|
private init() {
|
||||||
let cfg = AppConstants.VPN.baseConfiguration()
|
let cfg = AppConstants.VPN.baseConfiguration()
|
||||||
do {
|
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) {
|
if let content = String(data: data, encoding: .utf8) {
|
||||||
log.verbose("Service JSON:")
|
log.verbose("Service JSON:")
|
||||||
log.verbose(content)
|
log.verbose(content)
|
||||||
|
@ -76,7 +78,7 @@ class TransientStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
func serialize() {
|
func serialize() {
|
||||||
try? JSONEncoder().encode(service).write(to: serviceURL)
|
try? JSONEncoder().encode(service).write(to: TransientStore.serviceURL)
|
||||||
try? service.saveProfiles()
|
try? service.saveProfiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue