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

Function getStorageParams

src/controller/storage/storage.ts:176–209  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

174
175//获取存储
176async function getStorageParams(name: string): Promise<ParametersType> {
177 const storage = searchStorage(name)
178
179 switch (storage?.framework) {
180 case 'rclone': {
181 const result = await rclone_api_post('/config/get', {
182 name: storage?.name,
183 })
184 return result || {}
185 }
186 case 'openlist': {
187 const params = (
188 await openlist_api_get('/api/admin/storage/get', {
189 id: storage?.other?.openlist?.id,
190 })
191 ).data
192 // 安全解析 addition 字段
193 if (params.addition && typeof params.addition === 'string') {
194 try {
195 params.addition = JSON.parse(params.addition)
196 } catch (parseError) {
197 console.warn(`Failed to parse addition field for storage ${storage?.name}:`, parseError)
198 console.warn('Raw addition value:', params.addition)
199 // 保留原值,避免崩溃
200 params.addition = {}
201 }
202 } else if (!params.addition) {
203 params.addition = {}
204 }
205 return params
206 }
207 }
208 return {}
209}
210
211//转换存储路径
212const convertStoragePath = (

Callers 1

editModeFunction · 0.90

Calls 3

rclone_api_postFunction · 0.90
openlist_api_getFunction · 0.90
searchStorageFunction · 0.85

Tested by

no test coverage detected