agentDir 获取Agent的存储目录
(agentID string)
| 50 | |
| 51 | // agentDir 获取Agent的存储目录 |
| 52 | func (js *JSONStore) agentDir(agentID string) string { |
| 53 | // 优先使用原始 AgentID 目录(兼容旧数据,主要用于已有的 *nix 环境) |
| 54 | rawDir := filepath.Join(js.baseDir, agentID) |
| 55 | if fi, err := os.Stat(rawDir); err == nil && fi.IsDir() { |
| 56 | return rawDir |
| 57 | } |
| 58 | |
| 59 | // 否则使用经过清洗后的目录名,避免 Windows 等平台上非法路径 |
| 60 | safeID := sanitizeAgentIDForPath(agentID) |
| 61 | return filepath.Join(js.baseDir, safeID) |
| 62 | } |
| 63 | |
| 64 | // ensureAgentDir 确保Agent目录存在 |
| 65 | func (js *JSONStore) ensureAgentDir(agentID string) error { |
no test coverage detected