Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: keep database-import staging inside the caller's TMPDIR (#11684)
[._.]/ Adam Eivyd3aea931eb46
diff --git a/server/lib/databaseMaintenanceWorker.test.js b/server/lib/databaseMaintenanceWorker.test.jsindex fcb4d4716a..c3717898b6 100644--- a/server/lib/databaseMaintenanceWorker.test.js+++ b/server/lib/databaseMaintenanceWorker.test.js@@ -86,7 +86,9 @@ beforeEach(() => {cutover = installCutoverStubs(root, stubs.dir, { source, target });writeFileSync(join(root, '.env'), 'PGMODE=native\n');strays = [];- env = { ...process.env, NODE_ENV: 'test', PORTOS_DATA_ROOT: root, PATH: `${stubs.bin}${delimiter}${process.env.PATH}`,+ mkdirSync(join(root, 'tmp'));+ env = { ...process.env, NODE_ENV: 'test', PORTOS_DATA_ROOT: root,+ TMPDIR: join(root, 'tmp'), TMP: join(root, 'tmp'), TEMP: join(root, 'tmp'), PATH: `${stubs.bin}${delimiter}${process.env.PATH}`,PGPASSWORD: 'example-password', PGHOST: 'inherited.example.invalid', PGHOSTADDR: '192.0.2.10',NODE_OPTIONS: `--import=${installPm2Stub()}` };delete env.VITEST;diff --git a/server/services/databaseMaintenanceTransfer.js b/server/services/databaseMaintenanceTransfer.jsindex 5efddd0d78..6cdc832d53 100644--- a/server/services/databaseMaintenanceTransfer.js+++ b/server/services/databaseMaintenanceTransfer.js@@ -61,6 +61,7 @@ function hasCompletionMarker(path) {function runDbScript(action, endpoint, argument, dumpDir, expectedSha256) {const env = { PATH: process.env.PATH ?? '', HOME: process.env.HOME ?? PATHS.installRoot,PGPASSWORD: process.env.PGPASSWORD || 'portos', PORTOS_DUMP_DIR: dumpDir, LC_ALL: 'C',+ ...Object.fromEntries(["TMPDIR", "TMP", "TEMP"].filter(key => process.env[key]).map(key => [key, process.env[key]])),...(expectedSha256 ? { PORTOS_IMPORT_SHA256: expectedSha256 } : {}) };const args = [join(PATHS.root, 'scripts', 'db.sh'), action, '--endpoint',endpoint.host, String(endpoint.port), endpoint.user, endpoint.database, argument];diff --git a/server/services/databaseMaintenanceTransfer.test.js b/server/services/databaseMaintenanceTransfer.test.jsindex 7e69d3009d..036958347e 100644--- a/server/services/databaseMaintenanceTransfer.test.js+++ b/server/services/databaseMaintenanceTransfer.test.js@@ -85,7 +85,9 @@ beforeEach(({ onTestFailed }) => {PGHOST: 'inherited.example.invalid', PGPORT: '1', PGUSER: 'inherited', PGDATABASE: 'inherited',PGHOSTADDR: '192.0.2.10', PGSERVICE: 'inherited', PGSERVICEFILE: '/example/pg_service.conf',PGOPTIONS: '-c search_path=inherited',+ TMPDIR: join(root, 'tmp'),});+ mkdirSync(join(root, 'tmp'));});afterEach(async () => {for (const key of Object.keys(process.env)) if (!(key in savedEnv)) delete process.env[key];@@ -173,6 +175,8 @@ describe.skipIf(process.platform === 'win32')('offline database transfer', () =>expect(load).toBe(`psql ${endpointArgs(target)} -v ON_ERROR_STOP=1 --single-transaction`);// Inherited libpq endpoint/option variables never reach the client tools.expect(stubs.receivedVariables()).toEqual(['PGPASSWORD']);+ // The caller's TMPDIR is forwarded so import staging stays inside it.+ expect(stubs.receivedTmpdirs()).toEqual([join(root, 'tmp')]);expect(stubs.calls()).not.toMatch(/inherited|192\.0\.2\.10/);expect(stubs.imported()).toBe(STUB_DUMP_COMPLETE);// The source recovery dump is retained, recorded, and bound to this operation.diff --git a/server/test/fixtures/databaseTransferStubs.js b/server/test/fixtures/databaseTransferStubs.jsindex eb512d651a..657dc9d24f 100644--- a/server/test/fixtures/databaseTransferStubs.js+++ b/server/test/fixtures/databaseTransferStubs.js@@ -39,7 +39,7 @@ export function installDatabaseStubs(root) {const bin = join(dir, 'bin');mkdirSync(bin, { recursive: true });const R = quote(dir);- const logInvocation = name => `{ echo "${name} $*"; env | grep '^PG' | sort | sed 's/^/env /'; } >> "$R/calls.log"`;+ const logInvocation = name => `{ echo "${name} $*"; env | grep '^PG' | sort | sed 's/^/env /'; echo "tmpdir \${TMPDIR:-}"; } >> "$R/calls.log"`;const phase = (kind, event) => `echo "$$ ${kind} ${event} $(date +%s)" >> "$R/phases.log"`;const pause = kind => `: > "$R/${kind}-started"; while [ ! -e "$R/${kind}-release" ]; do sleep 0.05; done`;writeStub(join(bin, 'uname'), '#!/bin/sh\necho Linux\n');@@ -141,6 +141,9 @@ echo "import-commit" >> "$R/events.log"// PG* variable names each stub receivedreceivedVariables: () => [...new Set(read('calls.log').split('\n').filter(line => line.startsWith('env ')).map(line => line.slice(4).split('=')[0]))].sort(),+ // TMPDIR each stub inherited through db.sh (empty string when none reached it)+ receivedTmpdirs: () => [...new Set(read('calls.log').split('\n')+ .filter(line => line.startsWith('tmpdir ')).map(line => line.slice(7)))],writerPid: pid => writeFileSync(join(dir, 'writer.pid'), String(pid)),timed,report,