MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / streamImport

Function streamImport

apps/desktop/main/worker/workerManager.ts:518–548  ·  view source on GitHub ↗
(
  filePath: string,
  onProgress?: (progress: ParseProgress) => void,
  formatOptions?: Record<string, unknown>,
  externalSessionId?: string
)

Source from the content-addressed store, hash-verified

516 * @param formatOptions 格式特定选项(如 Telegram 的 chatIndex)
517 */
518export async function streamImport(
519 filePath: string,
520 onProgress?: (progress: ParseProgress) => void,
521 formatOptions?: Record<string, unknown>,
522 externalSessionId?: string
523): Promise<StreamImportResult> {
524 assertDataDirCompatibleNow()
525
526 const result = await sendToWorkerWithProgress<StreamImportResult>(
527 'streamImport',
528 { filePath, formatOptions, externalSessionId },
529 onProgress
530 )
531 if (!result.success || !result.sessionId) return result
532
533 try {
534 raiseChatDbCompatibilityGate(getPathProvider(), {
535 version: getDesktopAppVersion(app.getVersion()),
536 kind: 'desktop',
537 })
538 } catch (error) {
539 deleteImportedSessionFiles(result.sessionId)
540 return {
541 success: false,
542 error: error instanceof Error ? error.message : String(error),
543 diagnostics: result.diagnostics,
544 }
545 }
546
547 return result
548}
549
550function deleteImportedSessionFiles(sessionId: string): void {
551 const dbPath = path.join(getDbDir(), `${sessionId}.db`)

Callers

nothing calls this directly

Calls 6

getPathProviderFunction · 0.90
getDesktopAppVersionFunction · 0.90
getVersionMethod · 0.65

Tested by

no test coverage detected