| 50 | } |
| 51 | |
| 52 | function identify(dbPath: string): FileIdentity | null { |
| 53 | try { |
| 54 | const st = fs.statSync(dbPath); |
| 55 | let walSize = 0; |
| 56 | let walMtimeMs = 0; |
| 57 | try { |
| 58 | const wal = fs.statSync(`${dbPath}-wal`); |
| 59 | walSize = wal.size; |
| 60 | walMtimeMs = wal.mtimeMs; |
| 61 | } catch { |
| 62 | // No WAL sidecar: either not in WAL mode, or fully checkpointed. Both are |
| 63 | // "nothing pending", which is what zeroes mean here. |
| 64 | } |
| 65 | return { |
| 66 | ino: st.ino, |
| 67 | birthtimeMs: st.birthtimeMs, |
| 68 | size: st.size, |
| 69 | mtimeMs: st.mtimeMs, |
| 70 | walSize, |
| 71 | walMtimeMs, |
| 72 | }; |
| 73 | } catch { |
| 74 | return null; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | function sameFile(a: FileIdentity | null, b: FileIdentity | null): boolean { |
| 79 | if (a === null || b === null) return false; |