Skip to content

Commit

Permalink
Fix config lost.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFq1 committed Aug 1, 2022
1 parent aed8d82 commit f385621
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ extension AppDelegate {
case StartMetaError.helperNotFound:
unc.postMetaErrorNotice(msg: "Can't connect to helper.")
case StartMetaError.startMetaFailed(let s):
unc.postConfigErrorNotice(msg: s)
unc.postMetaErrorNotice(msg: s)
case StartMetaError.pushConfigFailed(let s):
unc.postConfigErrorNotice(msg: s)
default:
Expand All @@ -780,15 +780,24 @@ extension AppDelegate {
return
}
if !FileManager.default.fileExists(atPath: path) {
Logger.log("\(configName) not exists")
if let config = RemoteConfigManager.shared.configs.first(where: { $0.name == configName }) {
Logger.log("Try to download remote config \(configName)")
RemoteConfigManager.updateConfig(config: config) {
if let error = $0 {
Logger.log("Download remote config failed, \(error)")
resolver.reject(StartMetaError.remoteConfigMissing)
} else {
Logger.log("Download remote config success")
resolver.fulfill_()
}
}
} else {
if configName != "config" {
ConfigManager.selectConfigName = "config"
}

Logger.log("Try to copy default config")
ICloudManager.shared.setup()
ConfigFileManager.copySampleConfigIfNeed()
resolver.fulfill_()
Expand Down

0 comments on commit f385621

Please sign in to comment.