Skip to content

Commit ee67bfb

Browse files
fix(server): prefer the real-path No project over an older duplicate
AI-assisted; verified with the tests and tools listed above.
1 parent dd92ef1 commit ee67bfb

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎apps/server/src/project/ManagedProjectFolders.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ it.effect(
223223
title: "No project",
224224
workspaceRoot: resolvedRealRoot,
225225
});
226+
// The empty duplicate older servers created under the configured spelling.
227+
yield* projects.create({
228+
commandId: CommandId.make("no-project-duplicate"),
229+
projectId: ProjectId.make("project:no-project-duplicate"),
230+
title: "No project",
231+
workspaceRoot: root,
232+
});
226233

227234
assert.isTrue(yield* scratch.isScratchProject(projectId));
228235
assert.equal((yield* scratch.ensureScratchProject).projectId, projectId);
@@ -236,7 +243,7 @@ it.effect(
236243
const snapshot = yield* projects.snapshot;
237244
assert.lengthOf(
238245
snapshot.projects.filter((project) => project.title === "No project"),
239-
1,
246+
2,
240247
);
241248
}),
242249
),

‎apps/server/src/project/ManagedProjectFolders.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ const make = Effect.gen(function* () {
278278
.pipe(Effect.mapError((cause) => new ScratchFolderError({ folder, cause })));
279279

280280
// A symlinked scratch folder has two spellings, and No project may be stored under either.
281+
// Real path first: older servers left an empty duplicate under the configured spelling.
281282
const realPathOrResolved = (folder: string) =>
282283
fileSystem.realPath(folder).pipe(Effect.orElseSucceed(() => path.resolve(folder)));
283284

284285
const scratchRootSpellings = (root: string) =>
285-
realPathOrResolved(root).pipe(Effect.map((real) => (real === root ? [root] : [root, real])));
286+
realPathOrResolved(root).pipe(Effect.map((real) => (real === root ? [root] : [real, root])));
286287

287288
const existingScratchProject = Effect.fn("ManagedProjectFolders.existingScratchProject")(
288289
function* (root: string) {

0 commit comments

Comments
 (0)