mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 08:03:13 +00:00
30 lines
928 B
TypeScript
30 lines
928 B
TypeScript
import type { IFilesystemProvider } from './types'
|
|
|
|
const sshProviders = new Map<string, IFilesystemProvider>()
|
|
|
|
export const SSH_FILESYSTEM_PROVIDER_UNAVAILABLE_MESSAGE =
|
|
'Remote connection dropped. Click Reconnect on the SSH target before retrying.'
|
|
|
|
export function registerSshFilesystemProvider(
|
|
connectionId: string,
|
|
provider: IFilesystemProvider
|
|
): void {
|
|
sshProviders.set(connectionId, provider)
|
|
}
|
|
|
|
export function unregisterSshFilesystemProvider(connectionId: string): void {
|
|
sshProviders.delete(connectionId)
|
|
}
|
|
|
|
export function getSshFilesystemProvider(connectionId: string): IFilesystemProvider | undefined {
|
|
return sshProviders.get(connectionId)
|
|
}
|
|
|
|
export function requireSshFilesystemProvider(connectionId: string): IFilesystemProvider {
|
|
const provider = getSshFilesystemProvider(connectionId)
|
|
if (!provider) {
|
|
throw new Error(SSH_FILESYSTEM_PROVIDER_UNAVAILABLE_MESSAGE)
|
|
}
|
|
return provider
|
|
}
|