(w http.ResponseWriter, r *http.Request)
| 338 | } |
| 339 | |
| 340 | func (s *Server) selectVault(w http.ResponseWriter, r *http.Request) { |
| 341 | if osPath := strings.TrimSpace(os.Getenv("ZENNOTES_VAULT_PATH")); osPath != "" { |
| 342 | http.Error(w, "vault path is managed by ZENNOTES_VAULT_PATH", http.StatusConflict) |
| 343 | return |
| 344 | } |
| 345 | var req struct { |
| 346 | Path string `json:"path"` |
| 347 | } |
| 348 | if err := readJSON(r, &req); err != nil { |
| 349 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 350 | return |
| 351 | } |
| 352 | if strings.TrimSpace(req.Path) == "" { |
| 353 | http.Error(w, "vault path is required", http.StatusBadRequest) |
| 354 | return |
| 355 | } |
| 356 | allowedPath, err := s.ensureBrowsePathAllowed(req.Path) |
| 357 | if err != nil { |
| 358 | writeError(w, err) |
| 359 | return |
| 360 | } |
| 361 | nextVault, err := s.switchVaultRoot(allowedPath) |
| 362 | if err != nil { |
| 363 | writeError(w, err) |
| 364 | return |
| 365 | } |
| 366 | writeJSON(w, http.StatusOK, nextVault.Info()) |
| 367 | } |
| 368 | |
| 369 | type directoryBrowseEntry struct { |
| 370 | Name string `json:"name"` |
nothing calls this directly
no test coverage detected