Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions apps/server/src/provider/Drivers/AntigravityDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,25 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
instanceId,
);
// No process of this instance exists yet, so every runtime temp
// directory left under the profile is an orphan from a killed server.
yield* removeAntigravityRuntimeTempDirs(
resolveAntigravityRuntimeTempDirectory(profileDirectory),
).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem));
// directory left behind is an orphan from a killed server. Sweep the
// legacy location too: previous versions nested the runtime temp dir
// under the profile, and those orphans would otherwise never be
// reclaimed.
const runtimeTempDirectory =
resolveAntigravityRuntimeTempDirectory(profileDirectory);
yield* removeAntigravityRuntimeTempDirs(runtimeTempDirectory).pipe(
Effect.provideService(FileSystem.FileSystem, fileSystem),
);
const legacyRuntimeTempDirectory = path.join(
profileDirectory,
"antigravity-acp",
"tmp",
);
if (legacyRuntimeTempDirectory !== runtimeTempDirectory) {
yield* removeAntigravityRuntimeTempDirs(
legacyRuntimeTempDirectory,
).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
const continuationIdentity = defaultProviderContinuationIdentity({
driverKind: DRIVER,
instanceId,
Expand Down
20 changes: 18 additions & 2 deletions apps/server/src/provider/antigravityAuthSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeCrypto from "node:crypto";
import * as NodeFSP from "node:fs/promises";
// @effect-diagnostics-next-line nodeBuiltinImport:off - resolveAntigravityProfileDirectory is a pure sync helper, so it cannot use the Path service.
import * as NodePath from "node:path";
import * as NodeOS from "node:os";

import type { AntigravityAuthMethod, ProviderInstanceId } from "@t3tools/contracts";
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
Expand Down Expand Up @@ -194,8 +195,23 @@ export function resolveAntigravityProfileDirectory(
return NodePath.join(stateDir, "providers", "antigravity", directoryName);
}

/** Parent of the per-process runtime temp directories inside a profile. */
export function resolveAntigravityRuntimeTempDirectory(profileDirectory: string): string {
/** Parent of the per-process runtime temp directories. */
export function resolveAntigravityRuntimeTempDirectory(
profileDirectory: string,
platform: NodeJS.Platform = process.platform,
): string {
if (platform === "win32") {
// The profile directory already nests ~114 chars deep on Windows, which
// pushes the PyInstaller bundle's extraction paths past MAX_PATH (260)
// and kills the server during startup. Keep the runtime temp directory
// under the system temp dir instead; it stays T3-owned so the driver
// reclaims it the same way.
const scope = NodeCrypto.createHash("sha256")
.update(profileDirectory)
.digest("hex")
.slice(0, 16);
return NodePath.join(NodeOS.tmpdir(), "t3-antigravity", scope);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return NodePath.join(profileDirectory, "antigravity-acp", "tmp");
}

Expand Down
Loading