Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 836b5e3

Browse files
committed
feat: check tool when first loaded
1 parent 1aceece commit 836b5e3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

InjectGUI/Backend/InjectConfiguration.swift

+15-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ class InjectConfiguration: ObservableObject {
2525
]
2626

2727
private init() {
28-
// 开发环境默认关掉每次启动下载捏,因为防止疯狂重新编译而导致一直在获取资源
29-
// 可以在 SettingView 里面主动下载资源,不需要动这里
30-
// #if !DEBUG && !TEST
31-
// update()
32-
// #else
33-
updateRemoteConf() // 配置还是需要 Fetch 的
34-
// #endif
28+
firstLoadCheckAndDownload()
29+
updateRemoteConf()
30+
}
31+
32+
func firstLoadCheckAndDownload() {
33+
let path = getApplicationSupportDirectory().path
34+
for tool in injectTools {
35+
let _url = URL(fileURLWithPath: path).appendingPathComponent(tool)
36+
if !FileManager.default.fileExists(atPath: _url.path) {
37+
print("[*] First load, downloading \(tool)...")
38+
downloadInjectTool(name: tool)
39+
} else {
40+
print("[*] First load, \(tool) already exists.")
41+
}
42+
}
3543
}
3644

3745
private func downloadConfig(data: Data?) {

0 commit comments

Comments
 (0)