forked from doctly/switchboard
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfolder-index-state.js
More file actions
31 lines (26 loc) · 1021 Bytes
/
Copy pathfolder-index-state.js
File metadata and controls
31 lines (26 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const { enumerateSessionFiles } = require('./read-session-file');
function getFolderIndexMtimeMs(folderPath) {
let indexMtimeMs = 0;
try {
indexMtimeMs = fs.statSync(folderPath).mtimeMs;
} catch {
return 0;
}
// Stat every transcript this folder would index — top-level sessions AND
// subagent transcripts under <folder>/<id>/subagents/ — using the same
// enumeration as refreshFolder. Session files are appended in place, which
// bumps the file mtime but often leaves the containing directory mtime
// unchanged; and a folder whose ONLY change was a subagent transcript would
// be missed entirely if we only readdir'd the top level.
try {
for (const { filePath } of enumerateSessionFiles(folderPath)) {
try {
const fileMtimeMs = fs.statSync(filePath).mtimeMs;
if (fileMtimeMs > indexMtimeMs) indexMtimeMs = fileMtimeMs;
} catch {}
}
} catch {}
return indexMtimeMs;
}
module.exports = { getFolderIndexMtimeMs };