Skip to content

Commit bc8583b

Browse files
fix(server): storage cleanup keeps worktrees whose file listing exceeds the inspection limit (pingdotgg#26593)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent dab06c0 commit bc8583b

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎apps/server/src/storageCleanup.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,6 +2678,36 @@ describe("storage cleanup reports and local file policies", () => {
26782678
}),
26792679
),
26802680
);
2681+
it.live.each([
2682+
["uncommitted-changes", "untracked", "Local changes exceed the inspection limit"],
2683+
["any-local-files", "ignored", "Ignored files exceed the inspection limit"],
2684+
] as const)(
2685+
"keeps a worktree under %s when its %s file listing exceeds the inspection limit",
2686+
([policy, kind, reason]) =>
2687+
runCleanupTest(
2688+
Effect.gen(function* () {
2689+
const { service, fs, worktree, setPolicy } = yield* cleanupFixture();
2690+
setPolicy(policy);
2691+
const files = Array.from({ length: 3000 }, (_, i) =>
2692+
kind === "untracked"
2693+
? `${worktree}/many/untracked-file-with-a-long-name-${i}.txt`
2694+
: `${worktree}/many/ignored-directory-with-a-long-name-${i}/.env`,
2695+
);
2696+
yield* fs.makeDirectory(`${worktree}/many`);
2697+
yield* Effect.forEach(
2698+
files,
2699+
(file) =>
2700+
Effect.gen(function* () {
2701+
if (kind === "ignored") yield* fs.makeDirectory(file.slice(0, -"/.env".length));
2702+
yield* fs.writeFileString(file, "local\n");
2703+
}),
2704+
{ concurrency: 64, discard: true },
2705+
);
2706+
expect((yield* service.runNow).entries[0]).toMatchObject({ outcome: "kept", reason });
2707+
expect(yield* fs.exists(files[0]!)).toBe(true);
2708+
}),
2709+
),
2710+
);
26812711
it.live("serializes concurrent requests and returns each run's report", () =>
26822712
runCleanupTest(
26832713
Effect.gen(function* () {

‎apps/server/src/storageCleanup.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ const make = Effect.gen(function* () {
654654
: "--untracked-files=all",
655655
],
656656
maxOutputBytes: 64 * 1024,
657+
appendTruncationMarker: true,
657658
});
658659
if (status.stdoutTruncated) return "local changes exceed the inspection limit";
659660
const records = status.stdout.split("\0").filter(Boolean);
@@ -669,6 +670,7 @@ const make = Effect.gen(function* () {
669670
cwd,
670671
args: ["ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
671672
maxOutputBytes: 64 * 1024,
673+
appendTruncationMarker: true,
672674
});
673675
if (ignored.stdoutTruncated) return "ignored files exceed the inspection limit";
674676
const file = ignored.stdout

0 commit comments

Comments
 (0)