MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / init

Method init

ssh/ssh.ts:162–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160 }
161
162 private static async init(): Promise<void> {
163 if (this.initialized) return;
164
165 // 简单的锁机制防止并发初始化
166 while (this.initLock) {
167 await new Promise(resolve => setTimeout(resolve, 10));
168 }
169
170 if (this.initialized) return;
171 this.initLock = true;
172
173 try {
174 this.configPath = path.join(
175 createDirectoryInAssets("sshkey"),
176 "sshkey_config.json"
177 );
178 this.db = await JSONFilePreset<Record<string, any>>(
179 this.configPath,
180 { ...DEFAULT_CONFIG }
181 );
182 this.initialized = true;
183 } catch (error) {
184 console.error("[ssh] 初始化配置失败:", error);
185 } finally {
186 this.initLock = false;
187 }
188 }
189
190 static async get(key: string, defaultValue?: string): Promise<string> {
191 await this.init();

Callers 2

getMethod · 0.95
setMethod · 0.95

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected