mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
Make desktop proxy saves await Electron session proxy application before model download proxy resolution. Resolve HTTP, HTTPS, and SOCKS system proxy rules for semantic index model downloads while preserving DIRECT precedence.
22 lines
563 B
TypeScript
22 lines
563 B
TypeScript
export class ProxyApplyQueue {
|
|
private pendingApply: Promise<unknown> | null = null
|
|
|
|
apply<T>(task: () => Promise<T>): Promise<T> {
|
|
const previous = this.pendingApply ?? Promise.resolve()
|
|
const current = previous.catch(() => undefined).then(task)
|
|
this.pendingApply = current
|
|
|
|
const clear = () => {
|
|
if (this.pendingApply === current) this.pendingApply = null
|
|
}
|
|
current.then(clear, clear)
|
|
|
|
return current
|
|
}
|
|
|
|
async waitForPending(): Promise<void> {
|
|
const pending = this.pendingApply
|
|
if (pending) await pending
|
|
}
|
|
}
|