Makelore 2.0 initial clean snapshot
This commit is contained in:
38
electron/main/relaunch-on-replaced-app.ts
Normal file
38
electron/main/relaunch-on-replaced-app.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user