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

Function convertStoragePath

src/controller/storage/storage.ts:212–246  ·  view source on GitHub ↗
(
  storageName: string,
  path?: string,
  _isDir?: boolean,
  noStorageName: boolean = false,
  onlyStorageName: boolean = false
)

Source from the content-addressed store, hash-verified

210
211//转换存储路径
212const convertStoragePath = (
213 storageName: string,
214 path?: string,
215 _isDir?: boolean,
216 noStorageName: boolean = false,
217 onlyStorageName: boolean = false
218): string => {
219 if (path === '/') {
220 path = ''
221 }
222 const storage = searchStorage(storageName)
223 console.log(storage)
224
225 switch (storage?.framework) {
226 case 'rclone':
227 return (
228 (noStorageName ? '' : storageName + ':') +
229 (onlyStorageName ? '' : path ? formatPathRclone(path) : '')
230 )
231 case 'openlist': {
232 // 修复双斜杠问题:确保 path 不以 / 开头再拼接
233 const normalizedPath = path && path.startsWith('/') ? path.substring(1) : path
234 return (
235 (noStorageName ? '' : openlistInfo.markInRclone + ':') +
236 (onlyStorageName
237 ? ''
238 : normalizedPath
239 ? formatPathRclone(storageName + '/' + normalizedPath)
240 : storageName)
241 )
242 }
243 default:
244 return ''
245 }
246}
247
248function searchStorage(keyword: string): StorageList | undefined {
249 for (const storage of rcloneInfo.storageList) {

Callers 12

changeFunction · 0.90
mountStorageFunction · 0.90
getFileListFunction · 0.85
delFileFunction · 0.85
delDirFunction · 0.85
mkDirFunction · 0.85
copyFileFunction · 0.85
moveFileFunction · 0.85
copyDirFunction · 0.85
moveDirFunction · 0.85
syncFunction · 0.85
uploadFileRequestFunction · 0.85

Calls 2

searchStorageFunction · 0.85
formatPathRcloneFunction · 0.85

Tested by

no test coverage detected