Skip to content

Commit 809096f

Browse files
CopilotCodFrm
andcommitted
Apply rate limiting to open, openDir and create operations
Co-authored-by: CodFrm <22783163+CodFrm@users.noreply.github.com>
1 parent ed8865b commit 809096f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/filesystem/limiter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ export default class LimiterFileSystem implements FileSystem {
6060
}
6161

6262
async open(file: File): Promise<FileReader> {
63-
const reader = await this.fs.open(file);
63+
const reader = await this.limiter.execute(() => this.fs.open(file));
6464
return {
6565
read: (type) => this.limiter.execute(() => reader.read(type)),
6666
};
6767
}
6868

6969
async openDir(path: string): Promise<FileSystem> {
70-
const fs = await this.fs.openDir(path);
70+
const fs = await this.limiter.execute(() => this.fs.openDir(path));
7171
return new LimiterFileSystem(fs, this.limiter);
7272
}
7373

7474
async create(path: string): Promise<FileWriter> {
75-
const writer = await this.fs.create(path);
75+
const writer = await this.limiter.execute(() => this.fs.create(path));
7676
return {
7777
write: (content) => this.limiter.execute(() => writer.write(content)),
7878
};

0 commit comments

Comments
 (0)