Path: blob/main/extensions/copilot/src/extension/linkify/common/statCache.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IFileSystemService } from '../../../platform/filesystem/common/fileSystemService';6import { FileType } from '../../../platform/filesystem/common/fileTypes';7import { Uri } from '../../../vscodeTypes';89export interface IStatCache {10stat(uri: Uri): Promise<{ type: FileType } | undefined>;11}1213export class StatCache implements IStatCache {14private readonly cache = new Map<string, Promise<{ type: FileType } | undefined>>();1516constructor(17private readonly fileSystem: IFileSystemService,18) { }1920stat(uri: Uri): Promise<{ type: FileType } | undefined> {21const key = uri.toString();22const existing = this.cache.get(key);23if (existing) {24return existing;25}26const result = this.fileSystem.stat(uri).then(s => s, () => undefined);27this.cache.set(key, result);28return result;29}30}313233