Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.ts (1 of 1 file). Show all
Unified · Split
| @@ -135,26 +135,22 @@ export const make = Effect.gen(function* () { · 134 unmodified lines | ||
| 135 | 135 | relativeRealPath === ".." || |
| 136 | 136 | path.isAbsolute(relativeRealPath) |
| 137 | 137 | ) { |
| 138 | − return yield* Effect.fail( | |
| 139 | − new WorkspaceReadFileResolvedOutsideRootError({ | |
| 140 | − cwd: input.cwd, | |
| 141 | − relativePath: target.relativePath, | |
| 142 | − realWorkspaceRoot, | |
| 143 | − realTargetPath, | |
| 144 | − }), | |
| 145 | − ); | |
| 138 | + return yield* new WorkspaceReadFileResolvedOutsideRootError({ | |
| 139 | + cwd: input.cwd, | |
| 140 | + relativePath: target.relativePath, | |
| 141 | + realWorkspaceRoot, | |
| 142 | + realTargetPath, | |
| 143 | + }); | |
| 146 | 144 | } |
| 147 | 145 | |
| 148 | 146 | const handle = yield* fileSystem.open(realTargetPath, { flag: "r" }); |
| 149 | 147 | const stat = yield* handle.stat; |
| 150 | 148 | if (stat.type !== "File") { |
| 151 | − return yield* Effect.fail( | |
| 152 | − new WorkspaceReadFileNotFileError({ | |
| 153 | − cwd: input.cwd, | |
| 154 | − relativePath: target.relativePath, | |
| 155 | − fileType: stat.type, | |
| 156 | − }), | |
| 157 | − ); | |
| 149 | + return yield* new WorkspaceReadFileNotFileError({ | |
| 150 | + cwd: input.cwd, | |
| 151 | + relativePath: target.relativePath, | |
| 152 | + fileType: stat.type, | |
| 153 | + }); | |
| 158 | 154 | } |
| 159 | 155 | const byteLength = Number(stat.size); |
| 160 | 156 | const bytesToRead = Math.min(byteLength, PROJECT_READ_FILE_MAX_BYTES); |
| @@ -163,13 +159,11 @@ export const make = Effect.gen(function* () { · 2 unmodified lines | ||
| 163 | 159 | const fileBytes = buffer.subarray(0, Number(bytesRead)); |
| 164 | 160 | const nulByteOffset = fileBytes.indexOf(0); |
| 165 | 161 | if (nulByteOffset !== -1) { |
| 166 | − return yield* Effect.fail( | |
| 167 | − new WorkspaceReadFileBinaryFileError({ | |
| 168 | − cwd: input.cwd, | |
| 169 | − relativePath: target.relativePath, | |
| 170 | − nulByteOffset, | |
| 171 | − }), | |
| 172 | − ); | |
| 162 | + return yield* new WorkspaceReadFileBinaryFileError({ | |
| 163 | + cwd: input.cwd, | |
| 164 | + relativePath: target.relativePath, | |
| 165 | + nulByteOffset, | |
| 166 | + }); | |
| 173 | 167 | } |
| 174 | 168 | const contents = new TextDecoder("utf-8").decode(fileBytes); |
| 175 | 169 | return { |