MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / init

Method init

src/main/core/sync/syncEngine.ts:37–68  ·  view source on GitHub ↗

* 初始化同步引擎

()

Source from the content-addressed store, hash-verified

35 * 初始化同步引擎
36 */
37 async init(): Promise<void> {
38 // 加载同步配置
39 const config = await this.loadSyncConfig()
40 if (!config || !config.enabled) {
41 console.log('[Sync] 同步未启用')
42 return
43 }
44
45 // 解密密码
46 if (config.password && safeStorage.isEncryptionAvailable()) {
47 try {
48 const buffer = Buffer.from(config.password, 'base64')
49 config.password = safeStorage.decryptString(buffer)
50 } catch (error) {
51 console.error('[Sync] 解密密码失败:', error)
52 throw new Error('解密密码失败')
53 }
54 }
55
56 // 初始化 WebDAV 客户端
57 await this.webdavClient.init(config)
58
59 // 启动定时同步
60 this.startAutoSync(config.syncInterval)
61
62 // 如果启用了插件同步,启动插件目录监听
63 if (config.syncPlugins) {
64 pluginSyncWatcher.start()
65 }
66
67 console.log('[Sync] 同步引擎初始化完成')
68 }
69
70 /**
71 * 加载同步配置

Callers

nothing calls this directly

Calls 3

loadSyncConfigMethod · 0.95
startAutoSyncMethod · 0.95
startMethod · 0.45

Tested by

no test coverage detected