mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 03:42:21 +03:00
Release v3.8.42 — full CHANGELOG in CHANGELOG.md. CI: 103 checks green incl. CodeQL (all languages), Semgrep, all 8 unit shards, coverage, Node 24 compat, and integration tests. Full unit suite validated locally: 19437 pass / 0 fail. The 3 red checks are advisory and do not gate main (no required status checks): SonarCloud/SonarQube new-code coverage gate, and PR Test Policy (test-masking detector flagging the legitimate dead-Phind provider removal in #5530 — reviewed, correct). Includes cycle-close reconciliation + repair of inherited base-red tests from #5480/#5527/#5427/#5521 that the PR->release fast-path did not exercise.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import type { SqliteAdapter } from "./types";
|
|
import {
|
|
createNodeSqliteAdapterFromDatabase,
|
|
type NodeSqliteDatabaseLike,
|
|
} from "./nodeSqliteShared";
|
|
|
|
const CHECKPOINT_INTERVAL_MS = 60_000;
|
|
|
|
export async function createNodeSqliteAdapter(filePath: string): Promise<SqliteAdapter> {
|
|
// Suprimir ExperimentalWarning
|
|
const origEmit = process.emit.bind(process);
|
|
(process as NodeJS.Process).emit = function (name: string, ...args: unknown[]) {
|
|
if (
|
|
name === "warning" &&
|
|
args[0] !== null &&
|
|
typeof args[0] === "object" &&
|
|
"name" in (args[0] as object) &&
|
|
(args[0] as { name: string }).name === "ExperimentalWarning"
|
|
) {
|
|
return false;
|
|
}
|
|
return origEmit(name as never, ...(args as never[]));
|
|
} as typeof process.emit;
|
|
|
|
const { DatabaseSync } = (await import("node:sqlite" as never)) as {
|
|
DatabaseSync: new (path: string) => NodeSqliteDatabaseLike;
|
|
};
|
|
|
|
const db = new DatabaseSync(filePath);
|
|
|
|
const checkpointTimer = setInterval(() => {
|
|
try {
|
|
db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
} catch {}
|
|
}, CHECKPOINT_INTERVAL_MS);
|
|
(checkpointTimer as unknown as NodeJS.Timeout).unref?.();
|
|
|
|
function gracefulClose() {
|
|
clearInterval(checkpointTimer as unknown as NodeJS.Timeout);
|
|
try {
|
|
db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
} catch {}
|
|
}
|
|
|
|
const adapter = createNodeSqliteAdapterFromDatabase(db, filePath, gracefulClose);
|
|
|
|
process.once("beforeExit", () => {
|
|
adapter.close();
|
|
});
|
|
process.once("SIGINT", () => {
|
|
adapter.close();
|
|
process.exit(0);
|
|
});
|
|
process.once("SIGTERM", () => {
|
|
adapter.close();
|
|
process.exit(0);
|
|
});
|
|
|
|
return adapter;
|
|
}
|