fix(lanes): cloning into a deleted workspace's folder re-attaches it instead of failing UNIQUE
A workspace record outlives its folder (deleted from the File Explorer or a
shell). Cloning the same repo into that path again ran `git clone`, then
createLane hit idx_lanes_cwd_tool and answered 500 "UNIQUE constraint failed:
lanes.cwd, lanes.tool", leaving the new clone with no workspace on it.
POST /api/lanes/clone now looks for the caller's own workspace at exactly
that folder and tool and answers 200 { lane, created: false, path }, like
POST /ensure. Another user's workspace there is still refused before the
clone (folderTakenByOther), and a nested path still makes its own workspace.
This commit is contained in:
@@ -143,6 +143,25 @@ describe("POST /api/lanes/clone", () => {
|
||||
assert.equal(again.body.error.code, "EEXISTS");
|
||||
});
|
||||
|
||||
it("re-attaches a workspace whose folder was deleted instead of failing UNIQUE", async () => {
|
||||
const first = await request("POST", "/api/lanes/clone", {
|
||||
url: "https://forge.test/o/r.git",
|
||||
parent: WORK,
|
||||
name: "gone",
|
||||
});
|
||||
assert.equal(first.status, 201, JSON.stringify(first.body));
|
||||
fs.rmSync(path.join(WORK, "gone"), { recursive: true, force: true });
|
||||
const again = await request("POST", "/api/lanes/clone", {
|
||||
url: "https://forge.test/o/r.git",
|
||||
parent: WORK,
|
||||
name: "gone",
|
||||
});
|
||||
assert.equal(again.status, 200, JSON.stringify(again.body));
|
||||
assert.equal(again.body.created, false);
|
||||
assert.equal(again.body.lane.id, first.body.lane.id);
|
||||
assert.ok(fs.existsSync(path.join(WORK, "gone", "README.md")));
|
||||
});
|
||||
|
||||
it("clones over ssh with the user's key, kept in the clone's config", async () => {
|
||||
const made = await request("POST", "/api/me/git/ssh-key", {});
|
||||
assert.equal(made.status, 201);
|
||||
|
||||
Reference in New Issue
Block a user