Skip to content

Commit a48bf99

Browse files
committed
fix(server): file metadata lookups skip the server's own state files
1 parent f31ce3e commit a48bf99

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎apps/server/src/workspace/WorkspaceFileSystem.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
290290
const error = yield* workspaceFileSystem.readFile(input).pipe(Effect.flip);
291291
expect(error).toBeInstanceOf(WorkspacePaths.WorkspacePathOutsideRootError);
292292
}
293+
const metadata = yield* workspaceFileSystem.getMetadata({
294+
paths: [
295+
path.join(config.secretsDir, "example.bin"),
296+
path.join(config.stateDir, "statev2.sqlite"),
297+
config.stateDir,
298+
],
299+
});
300+
expect(metadata.entries).toEqual([null, null, { kind: "directory" }]);
293301
}),
294302
);
295303

‎apps/server/src/workspace/WorkspaceFileSystem.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ export const make = Effect.gen(function* () {
148148
// path makes Windows sign in to its host with the user's NTLM credentials.
149149
if (!path.isAbsolute(expandedPath) || isNetworkPath(expandedPath)) return null;
150150
const stat = yield* fileSystem.stat(expandedPath).pipe(Effect.option);
151-
if (stat._tag === "None") return null;
151+
// Server state files answer like missing paths, as readFile refuses them.
152+
if (stat._tag === "None" || (yield* isServerInternalPath(expandedPath))) return null;
152153
if (stat.value.type === "Directory") return { kind: "directory" } as const;
153154
if (stat.value.type !== "File") return { kind: "other" } as const;
154155
let mimeType: string | undefined;

0 commit comments

Comments
 (0)