History

Use idiomatic Effect filesystem and duration APIs

Cursor Agent committed 4 months ago

Commit 2ba84721 parent a4964b34 files · +97 −28Browse files

Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.ts (1 of 4 files). Show all

Unified · Split

apps/server/src/workspace/WorkspaceFileSystem.ts+26−24
@@ -140,30 +140,32 @@ export const make = Effect.gen(function* () { · 139 unmodified lines
140140 relativePath: input.relativePath,
141141 });
142142
143− const realWorkspaceRoot = yield* Effect.tryPromise({
144− try: () => NodeFSP.realpath(input.cwd),
145− catch: (cause) =>
146− new WorkspaceFileSystemOperationError({
147− workspaceRoot: input.cwd,
148− relativePath: input.relativePath,
149− resolvedPath: target.absolutePath,
150− operationPath: input.cwd,
151− operation: "realpath-workspace-root",
152− cause,
153− }),
154− });
155− const realTargetPath = yield* Effect.tryPromise({
156− try: () => NodeFSP.realpath(target.absolutePath),
157− catch: (cause) =>
158− new WorkspaceFileSystemOperationError({
159− workspaceRoot: input.cwd,
160− relativePath: input.relativePath,
161− resolvedPath: target.absolutePath,
162− operationPath: target.absolutePath,
163− operation: "realpath-target",
164− cause,
165− }),
166− });
143+ const realWorkspaceRoot = yield* fileSystem.realPath(input.cwd).pipe(
144+ Effect.mapError(
145+ (cause) =>
146+ new WorkspaceFileSystemOperationError({
147+ workspaceRoot: input.cwd,
148+ relativePath: input.relativePath,
149+ resolvedPath: target.absolutePath,
150+ operationPath: input.cwd,
151+ operation: "realpath-workspace-root",
152+ cause,
153+ }),
154+ ),
155+ );
156+ const realTargetPath = yield* fileSystem.realPath(target.absolutePath).pipe(
157+ Effect.mapError(
158+ (cause) =>
159+ new WorkspaceFileSystemOperationError({
160+ workspaceRoot: input.cwd,
161+ relativePath: input.relativePath,
162+ resolvedPath: target.absolutePath,
163+ operationPath: target.absolutePath,
164+ operation: "realpath-target",
165+ cause,
166+ }),
167+ ),
168+ );
167169 const relativeRealPath = path.relative(realWorkspaceRoot, realTargetPath);
168170 if (
169171 relativeRealPath.startsWith(`..${path.sep}`) ||