MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / importDirectory

Method importDirectory

src/services/import/fetch.ts:243–270  ·  view source on GitHub ↗
(
    source: File[] | string,
    _options?: ImportOptions,
    onProgress?: (p: ImportProgress) => void
  )

Source from the content-addressed store, hash-verified

241 }
242
243 async importDirectory(
244 source: File[] | string,
245 _options?: ImportOptions,
246 onProgress?: (p: ImportProgress) => void
247 ): Promise<ImportResult> {
248 if (typeof source === 'string') {
249 return { success: false, error: 'Directory path import is not supported in Web mode' }
250 }
251
252 if (source.length === 0) {
253 return { success: false, error: 'No files in directory' }
254 }
255
256 const form = new FormData()
257 for (const file of source) {
258 form.append('files', file)
259 form.append('relativePaths', file.webkitRelativePath || file.name)
260 }
261
262 const res = await fetchWithAuth(`${getBaseUrl()}/import-directory`, { method: 'POST', body: form })
263
264 if (!res.ok) {
265 const text = await res.text()
266 return { success: false, error: `HTTP ${res.status}: ${text}` }
267 }
268
269 return consumeSseStream<ImportResult>(res, { success: false, error: 'Unknown error' }, onProgress)
270 }
271}

Callers

nothing calls this directly

Calls 4

fetchWithAuthFunction · 0.90
getBaseUrlFunction · 0.90
consumeSseStreamFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected