Resolve backup subprocess paths with URL decoding
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import { Database } from "bun:sqlite";
|
import { Database } from "bun:sqlite";
|
||||||
import { chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, linkSync, mkdirSync, openSync, readdirSync, renameSync, rmSync, statSync, unlinkSync } from "node:fs";
|
import { chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, linkSync, mkdirSync, openSync, readdirSync, renameSync, rmSync, statSync, unlinkSync } from "node:fs";
|
||||||
import { dirname, join, resolve } from "node:path";
|
import { dirname, join, resolve } from "node:path";
|
||||||
@@ -86,7 +87,7 @@ export function restoreBackup(source: string, destination: string) {
|
|||||||
export async function runScheduledBackup(database: string, config: BackupConfig): Promise<number> {
|
export async function runScheduledBackup(database: string, config: BackupConfig): Promise<number> {
|
||||||
const source = new URL("../../scripts/scheduled-backup.ts", import.meta.url);
|
const source = new URL("../../scripts/scheduled-backup.ts", import.meta.url);
|
||||||
const built = new URL("../scripts/scheduled-backup.ts", import.meta.url);
|
const built = new URL("../scripts/scheduled-backup.ts", import.meta.url);
|
||||||
const script = (existsSync(source) ? source : built).pathname;
|
const script = fileURLToPath(existsSync(source) ? source : built);
|
||||||
const child = Bun.spawn([process.execPath, script, resolve(database), JSON.stringify(config)], {
|
const child = Bun.spawn([process.execPath, script, resolve(database), JSON.stringify(config)], {
|
||||||
stdout: "pipe", stderr: "ignore",
|
stdout: "pipe", stderr: "ignore",
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user