agentHostFileSystemProvider.ts ×11

Frontier kind: Code frontier

unlabeled · c_9eb9a8fb07e3

6 tests · 17163 LOC · 61 files · introduces 0 tests · 56 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges56 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1470 ranges17163 lines · 61 files · Browse complete extent
All tests (intent)
6 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 56 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/agentHostFileSystemProvider.ts 56 introduced LOC · 11 ranges

Open complete file

291
292 watch(resource: URI, opts: IWatchOptions): IDisposable {
293 > // `IFileSystemProvider.watch` is synchronous, but acquiring a agentHostFileSystemProvider.ts
294 > // connection may have to wait for a (re)registration and the
295 > // underlying AHP `createResourceWatch` + `subscribe` round-trip
296 > // is itself async. Additionally, watchers are long-lived: every
297 > // time the active connection for `authority` changes (reconnect,
298 > // fallback to an older registration, eviction followed by a fresh
299 > // registration, ...) we tear down any existing remote handle and
300 > // re-attach against the new connection. The class-level
301 > // {@link _onDidChangeConnection} event keeps us informed across
302 > // the full entry-eviction cycle.
303 > const store = new DisposableStore();
304 > const handleHolder = store.add(new MutableDisposable<IDisposable>());
305 > const authority = resource.authority;
306 > const params: CreateResourceWatchParams = {
307 > channel: ROOT_STATE_URI,
308 > uri: this._decodeUri(resource).toString(),
309 > recursive: opts.recursive,
310 > ...(opts.excludes.length > 0 ? { excludes: { items: [...opts.excludes] } } : {}),
311 > ...(opts.includes && opts.includes.length > 0
312 ? { includes: { items: opts.includes.map(p => typeof p === 'string' ? p : p.pattern) } }
313 : {}),
315 >
316 > // Track which connection the current handle was created against
317 > // so we ignore spurious change events that don't represent a
318 > // real swap (e.g. a stale registration disposal).
319 > let attached: IRemoteFilesystemConnection | undefined;
320 > let attaching = false;
321 > let pendingReattach = false;
322 >
323 > const reattach = async (): Promise<void> => {
324 > if (store.isDisposed) {
325 return;
326 }
327 > if (attaching) { agentHostFileSystemProvider.ts
328 pendingReattach = true;
329 return;
330 }
331 > const entry = this._authorities.get(authority); agentHostFileSystemProvider.ts
332 > const next = entry?.connections.at(-1);
333 > if (next === attached) {
334 return;
335 }
336 > handleHolder.clear(); agentHostFileSystemProvider.ts
337 > attached = undefined;
338 > const watchResource = next?.watchResource;
339 > if (!next || !watchResource) {
340 return;
341 }
342 > attaching = true; agentHostFileSystemProvider.ts
343 > const target = next;
344 > try {
345 > const handle = await watchResource.call(target, params);
346 if (store.isDisposed) {
347 handle.dispose();
349 }
350 const current = this._authorities.get(authority);
351 > if (!current || current.connections.at(-1) !== target) { agentHostFileSystemProvider.ts
352 // Active connection changed underneath us — toss this
353 // handle and let the pending reattach pick the new one.
364 });
365 attached = target;
366 > } catch (err) { agentHostFileSystemProvider.ts
367 this._onDidWatchError.fire(err instanceof Error ? err.message : String(err));
368 > } finally { agentHostFileSystemProvider.ts
369 > attaching = false;
370 > if (pendingReattach) {
371 pendingReattach = false;
372 void reattach();
373 }
375 > };
376 >
377 > store.add(this._onDidChangeConnection.event(a => {
378 if (a === authority) {
379 void reattach();
380 }
382 > void reattach();
383 >
384 > return store;
385 > }
386
387 async stat(resource: URI): Promise<IStat> {