Skip to content

Commit 671c169

Browse files
mweinbachclaude
andcommitted
fix(server): only sweep Codex staging dirs older than any real install
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent acd6ed1 commit 671c169

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎apps/server/src/provider/CodexInstallation.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ it.live("startup removes only stale staging directories", () =>
413413
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-codex-install-test-" });
414414
const managed = `${baseDir}/tools/codex`;
415415
// utimes takes seconds when given numbers.
416-
const stale = ((yield* Clock.currentTimeMillis) - 2 * 60 * 60_000) / 1000;
416+
const stale = ((yield* Clock.currentTimeMillis) - 25 * 60 * 60_000) / 1000;
417417
for (const name of [".install-stale", ".active-stale", ".install-live"]) {
418418
yield* fs.makeDirectory(`${managed}/${name}`, { recursive: true });
419419
}

‎apps/server/src/provider/CodexInstallation.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as ModelManifest from "./ModelManifest.ts";
2828
import { resolveProviderCompatibility } from "./providerCompatibility.ts";
2929

3030
const DRIVER = ProviderDriverKind.make("codex");
31-
const STAGING_STALE_AFTER_MS = 60 * 60_000;
31+
const STAGING_STALE_AFTER_MS = 24 * 60 * 60_000;
3232
const Version = Schema.String.check(Schema.isPattern(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/u));
3333
const ActiveRelease = Schema.Struct({ version: Version });
3434
const InstalledRelease = Schema.Struct({
@@ -703,8 +703,9 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
703703
yield* Effect.gen(function* () {
704704
// Clear staging directories left behind by an interrupted install so they
705705
// neither leak disk nor make an otherwise empty runtime look removable. Two
706-
// servers can share a home, so one touched within the last hour may be
707-
// another server's install in progress and stays.
706+
// servers can share a home, and writes below a staging directory do not
707+
// refresh its mtime, so only directories far older than any real install
708+
// (download is capped at 45 minutes) are treated as abandoned.
708709
let canRemove = false;
709710
if (yield* fs.exists(managedDirectory)) {
710711
const entries = yield* fs

0 commit comments

Comments
 (0)