Files
makelore/electron/main/relaunch-on-replaced-app.ts
2026-07-29 17:22:35 +08:00

39 lines
770 B
TypeScript

import { statSync } from 'node:fs';
export interface ExecutableSnapshot {
dev: number;
ino: number;
mtimeMs: number;
size: number;
}
export function snapshotExecutable(execPath: string): ExecutableSnapshot | null {
try {
const stat = statSync(execPath);
return {
dev: stat.dev,
ino: stat.ino,
mtimeMs: stat.mtimeMs,
size: stat.size,
};
} catch {
return null;
}
}
export function executableSnapshotChanged(
initial: ExecutableSnapshot | null,
current: ExecutableSnapshot | null,
): boolean {
if (!initial || !current) {
return false;
}
return (
initial.dev !== current.dev
|| initial.ino !== current.ino
|| initial.mtimeMs !== current.mtimeMs
|| initial.size !== current.size
);
}