@devries-cameron20 / t3code-1 / commits / 40f6f5b8f0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): clean old logs and artifacts under a symlinked T3 home (#24097)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 29, 2026 at 12:47 UTC 40f6f5b8f033628a672b7a9213c27cd64db05cb3
2 files changed +39 -1
apps/server/src/storageCleanup.test.ts
+36
@@ -1814,6 +1814,42 @@ describe("storage cleanup reports and local file policies", () => {
1814 }),
1815 ),
1816 );
1817 + it.live.each([
1818 + { linked: "home", outcome: "removed", reason: "Removed 1 rotated logs" },
1819 + { linked: "logs folder", outcome: "kept", reason: "No expired files" },
1820 + ] as const)(
1821 + "rotated logs behind a symlinked $linked are $outcome",
1822 + ({ linked, outcome, reason }) =>
1823 + runCleanupTest(
1824 + Effect.gen(function* () {
1825 + const fs = yield* FileSystem.FileSystem;
1826 + const config = yield* ServerConfig.ServerConfig;
1827 + const disk = yield* fs.realPath(yield* fs.makeTempDirectoryScoped());
1828 + yield* fs.makeDirectory(`${disk}/real/logs`, { recursive: true });
1829 + if (linked === "home") {
1830 + yield* fs.symlink(`${disk}/real`, `${disk}/home`);
1831 + } else {
1832 + yield* fs.makeDirectory(`${disk}/home`);
1833 + yield* fs.symlink(`${disk}/real/logs`, `${disk}/home/logs`);
1834 + }
1835 + yield* fs.writeFileString(`${disk}/real/logs/server.log.1`, "log");
1836 + yield* fs.utimes(`${disk}/real/logs/server.log.1`, 1, 1);
1837 + const { service, enableFiles, disable } = yield* cleanupFixture().pipe(
1838 + Effect.provideService(ServerConfig.ServerConfig, {
1839 + ...config,
1840 + logsDir: `${disk}/home/logs`,
1841 + }),
1842 + );
1843 + disable();
1844 + enableFiles();
1845 + const report = yield* service.runNow;
1846 + expect(report.entries.filter((entry) => entry.kind === "logs")).toMatchObject([
1847 + { outcome, reason },
1848 + ]);
1849 + expect(yield* fs.exists(`${disk}/real/logs/server.log.1`)).toBe(outcome === "kept");
1850 + }),
1851 + ),
1852 + );
1853 it.live("reports git failures without aborting the remaining categories", () =>
1854 runCleanupTest(
1855 Effect.gen(function* () {
apps/server/src/storageCleanup.ts
+3 -1
@@ -1059,8 +1059,10 @@ const make = Effect.gen(function* () {
1059 removed: { files: number; bytes: number },
1060 ) {
1061 if (days === null || !(yield* fs.exists(root))) return removed;
1062 + // A symlinked parent (a linked T3 home) is fine; a symlinked folder is not.
1063 const realRoot = yield* fs.realPath(root);
1063 - if (realRoot !== path.resolve(root)) return removed;
1064 + const realParent = yield* fs.realPath(path.dirname(root));
1065 + if (realRoot !== path.join(realParent, path.basename(root))) return removed;
1066 const visit = Effect.fn("StorageCleanup.visitFiles")(function* (
1067 directory: string,
1068 ): Effect.fn.Return<void, PlatformError | ServerSettingsError> {