(self)
| 29 | self._dir.mkdir(parents=True, exist_ok=True) |
| 30 | |
| 31 | async def _ensure_session_id(self) -> str: |
| 32 | if not self.session_id: |
| 33 | timestamp = datetime.now().strftime("%Y%m%d%H%M%S") |
| 34 | # Prefix with wall-clock time so recent sessions are easy to spot on disk. |
| 35 | self.session_id = f"{timestamp}-{uuid4().hex[:12]}" |
| 36 | await asyncio.to_thread(self._dir.mkdir, parents=True, exist_ok=True) |
| 37 | file_path = self._items_path(self.session_id) |
| 38 | if not file_path.exists(): |
| 39 | await asyncio.to_thread(file_path.write_text, "[]", encoding="utf-8") |
| 40 | return self.session_id |
| 41 | |
| 42 | async def get_session_id(self) -> str: |
| 43 | """Return the session id, creating one if needed.""" |
no test coverage detected