feat(index): db under .index/ dir

This commit is contained in:
Kristian Borgwarth 2026-03-22 22:05:41 +01:00
parent 5f9eba77eb
commit d9adf0e8df
3 changed files with 9 additions and 4 deletions

View file

@ -2,8 +2,6 @@ package handlers
import ( import (
"encoding/json" "encoding/json"
"log/slog"
"github.com/KristianJBorgwarth/dendrite.daemon/config" "github.com/KristianJBorgwarth/dendrite.daemon/config"
"github.com/KristianJBorgwarth/dendrite.daemon/core/rpc" "github.com/KristianJBorgwarth/dendrite.daemon/core/rpc"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence" "github.com/KristianJBorgwarth/dendrite.daemon/persistence"
@ -30,7 +28,6 @@ type InitializeHandler struct{}
func (h InitializeHandler) Handle(raw json.RawMessage) (any, *rpc.Error) { func (h InitializeHandler) Handle(raw json.RawMessage) (any, *rpc.Error) {
var params initializeCommand var params initializeCommand
slog.Info("initializing with params", "params", string(raw))
if err := json.Unmarshal(raw, &params); err != nil { if err := json.Unmarshal(raw, &params); err != nil {
return nil, &rpc.Error{ return nil, &rpc.Error{
Code: -32602, Code: -32602,

BIN
dendrite

Binary file not shown.

View file

@ -4,6 +4,7 @@ import (
"database/sql" "database/sql"
"embed" "embed"
"log/slog" "log/slog"
"os"
"path/filepath" "path/filepath"
"sort" "sort"
) )
@ -12,7 +13,14 @@ import (
var migrationsFS embed.FS var migrationsFS embed.FS
func InitializeIndex(vaultPath string) error { func InitializeIndex(vaultPath string) error {
dbPath := filepath.Join(vaultPath, "index.db") indexDir := filepath.Join(vaultPath, ".index")
if err := os.MkdirAll(indexDir, 0755); err != nil {
slog.Error("failed to create index directory", "error", err)
return err
}
dbPath := filepath.Join(indexDir, "index.db")
db, err := sql.Open("sqlite", dbPath) db, err := sql.Open("sqlite", dbPath)
if err != nil { if err != nil {