fix(host): cancellable listing scans and O(log window) insertion

capability.list gains an optional AbortSignal threaded from the RPC
carrier's request signal (the pickDirectory pattern): a disconnected or
timed-out caller stops the opendir loop instead of the scan outliving
its caller, and the abort surfaces as its own reason rather than a
directory-unreadable dressing. boundedInsert rejects a full window's
at-or-beyond-tail candidate on one comparison and binary-inserts
retained candidates, so an oversized level no longer pays a window scan
per dirent.
This commit is contained in:
creatixchu
2026-07-29 04:42:13 +08:00
parent da970ea269
commit 7503390590
17 changed files with 68 additions and 27 deletions
+4 -1
View File
@@ -65,13 +65,16 @@ export interface DirectoryPickerBrowseCapability {
/**
* List one directory level.
* @param path - absolute directory to list; absent lists the home directory.
* @param signal - caller lifetime; abort stops the scan (a stalled network
* directory must not outlive a disconnected caller) and rejects with the
* abort reason.
* @returns the level's listing with ancestry; backends bound the complete
* result, and a cut level reports `truncated`.
* @throws {DirectoryPickerError} `directory-unreadable` when the target is not fully
* qualified (a wire value must never resolve against the host cwd or, on
* Windows, its current drive) or cannot be listed.
*/
list(path?: string): Promise<DirectoryListing>
list(path?: string, signal?: AbortSignal): Promise<DirectoryListing>
/**
* Create one child directory under an existing parent.
* @param path - absolute existing parent directory.