MCPcopy
hub / github.com/coder/mux / readFile

Method readFile

src/node/services/sessionUsageService.ts:123–133  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

121 }
122
123 private async readFile(workspaceId: string): Promise<SessionUsageFile> {
124 try {
125 const data = await fs.readFile(this.getFilePath(workspaceId), "utf-8");
126 return JSON.parse(data) as SessionUsageFile;
127 } catch (error) {
128 if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
129 return this.createEmptyUsageFile();
130 }
131 throw error;
132 }
133 }
134
135 private async writeFile(workspaceId: string, data: SessionUsageFile): Promise<void> {
136 const filePath = this.getFilePath(workspaceId);

Callers 4

recordUsageMethod · 0.95
setTokenStatsCacheMethod · 0.95
rollUpUsageIntoParentMethod · 0.95
getSessionUsageMethod · 0.95

Calls 4

getFilePathMethod · 0.95
createEmptyUsageFileMethod · 0.95
readFileMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected