MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / runStartupTasksInBackground

Function runStartupTasksInBackground

src/controller/main.ts:88–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86}
87
88async function runStartupTasksInBackground() {
89 hooks.startup.storageInitDone = false
90 hooks.startup.storageSyncing = true
91 hooks.startup.storageInitFailed = false
92 hooks.upStartup()
93
94 const failedSteps = new Set<string>()
95 const runStep = async (label: string, fn: () => Promise<unknown>) => {
96 try {
97 await fn()
98 return true
99 } catch (e) {
100 console.error(`[startup] ${label} failed:`, e)
101 if (!failedSteps.has(label)) {
102 failedSteps.add(label)
103 Notification.warning({
104 id: `startup_step_failed_${label.replace(/\s+/g, '_')}`,
105 title: t('warning'),
106 content: t('startup_task_failed', { step: label }),
107 })
108 }
109 return false
110 }
111 }
112
113 hooks.retryStartupStorageSync = async () => {
114 hooks.startup.storageSyncing = true
115 hooks.startup.storageInitFailed = false
116 hooks.upStartup()
117 const refreshOk = await runStep('refresh storages and mounts', async () => {
118 await reupStorage()
119 await addOpenlistInRclone()
120 await reupMount()
121 })
122 hooks.startup.storageInitDone = refreshOk
123 hooks.startup.storageSyncing = false
124 hooks.startup.storageInitFailed = !refreshOk
125 hooks.upStartup()
126 }
127
128 await Promise.allSettled([
129 runStep('check notice', async () => {
130 await checkNotice()
131 hooks.upNotice()
132 }),
133 runStep('sync versions', async () => {
134 await Promise.allSettled([reupRcloneVersion(), reupOpenlistVersion()])
135 }),
136 runStep('update storage providers', updateStorageInfoList),
137 ])
138
139 const refreshOk = await runStep('refresh storages and mounts', async () => {
140 await reupStorage()
141 await addOpenlistInRclone()
142 await reupMount()
143 })
144 hooks.startup.storageInitDone = refreshOk
145 hooks.startup.storageSyncing = false

Callers 1

initFunction · 0.85

Calls 7

reupStorageFunction · 0.90
addOpenlistInRcloneFunction · 0.90
reupMountFunction · 0.90
checkNoticeFunction · 0.90
runStepFunction · 0.85
reupRcloneVersionFunction · 0.85
reupOpenlistVersionFunction · 0.85

Tested by

no test coverage detected