Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(db): see the unnamed temp files SQLite 3.54 opens on Linux

Maurice1ed77870f96e
diff --git a/server/tests/unit/db/connection.test.ts b/server/tests/unit/db/connection.test.ts
index a94838591..00a279a7b 100644
--- a/server/tests/unit/db/connection.test.ts
+++ b/server/tests/unit/db/connection.test.ts
@@ -87,8 +87,10 @@ describe('openDatabase', () => {
});
});
-// SQLite names every temp file etilqs_<random>. Linux unlinks the file the
-// moment it is opened, so it only shows among the process's open descriptors;
+// SQLite names every temp file etilqs_<random>, except where it can open it
+// without a name: from 3.54 on Linux uses O_TMPFILE, and such a file shows among
+// the process's open descriptors as <dir>/#<inode> (deleted). Before that, Linux
+// unlinked the named file the moment it was opened, so it showed only there too.
// Windows keeps it in the temp directory until it is closed. macOS offers
// neither view, which is why the test below does not run there.
const canSeeTempFiles = process.platform === 'linux' || process.platform === 'win32';
@@ -104,7 +106,7 @@ function sqliteTempFiles(): string[] {
return [];
}
})
- .filter((target) => target.includes('etilqs_'));
+ .filter((target) => target.includes('etilqs_') || /\/#\d+ \(deleted\)$/.test(target));
}
return fs.readdirSync(os.tmpdir()).filter((name) => name.startsWith('etilqs_'));
}