(stateDir: string)
| 126 | } |
| 127 | |
| 128 | private loadOrCreateSessionId(stateDir: string): string { |
| 129 | const filePath = path.join(stateDir, "memos-local", ".session"); |
| 130 | try { |
| 131 | const raw = fs.readFileSync(filePath, "utf-8").trim(); |
| 132 | const sep = raw.indexOf("|"); |
| 133 | if (sep > 0) { |
| 134 | const ts = parseInt(raw.slice(0, sep), 10); |
| 135 | const id = raw.slice(sep + 1); |
| 136 | if (id.length > 10 && Date.now() - ts < SESSION_TTL_MS) { |
| 137 | this.touchSession(filePath, id); |
| 138 | return id; |
| 139 | } |
| 140 | } |
| 141 | } catch {} |
| 142 | const newId = uuidv4(); |
| 143 | this.touchSession(filePath, newId); |
| 144 | return newId; |
| 145 | } |
| 146 | |
| 147 | private touchSession(filePath: string, id: string): void { |
| 148 | try { |
no test coverage detected