From 4025f038269c09bd78e611657b228039948271c5 Mon Sep 17 00:00:00 2001 From: Kristian <10348902@pm.me> Date: Wed, 10 Jun 2026 19:58:03 +0200 Subject: [PATCH] template path fix (#48) --- core/handlers/vault/initialize_handler.go | 5 +++++ persistence/store/vault_store.go | 3 ++- test/test_integration/create_note_handler_test.go | 2 +- test/test_integration/main_test.go | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/handlers/vault/initialize_handler.go b/core/handlers/vault/initialize_handler.go index 488476a..4eed265 100644 --- a/core/handlers/vault/initialize_handler.go +++ b/core/handlers/vault/initialize_handler.go @@ -3,6 +3,7 @@ package vault import ( "context" "encoding/json" + "errors" "log/slog" "github.com/KristianJBorgwarth/dendrite.daemon/core/services" @@ -45,6 +46,10 @@ func (h InitializeHandler) Handle(ctx context.Context, raw json.RawMessage) (any return nil, err } + if cmd.Config.VaultPath == "" { + return nil, errors.New("vault_path is empty — check your dendrite.nvim config") + } + store := store.NewVaultStore( cmd.Config.VaultName, cmd.Config.VaultPath, diff --git a/persistence/store/vault_store.go b/persistence/store/vault_store.go index c52a5b7..fe21286 100644 --- a/persistence/store/vault_store.go +++ b/persistence/store/vault_store.go @@ -44,7 +44,8 @@ func GetVaultStore() *VaultStore { func (vs *VaultStore) GetTemplatePath(templateName string) string { templateName = vs.fileTypeCheck(templateName) - return path.Join(vs.Config.TemplateDirectory(), templateName) + path := path.Join(vs.Config.VaultPath(), vs.Config.TemplateDirectory(), templateName) + return path } func (vs *VaultStore) fileTypeCheck(templateName string) string { diff --git a/test/test_integration/create_note_handler_test.go b/test/test_integration/create_note_handler_test.go index f9a1465..1fd4a10 100644 --- a/test/test_integration/create_note_handler_test.go +++ b/test/test_integration/create_note_handler_test.go @@ -55,7 +55,7 @@ func TestCreateNoteHandler_WithTemplate_CreatesNoteFileWithTagsAndReturnsPath(t handler := newCreateNoteHandler() vaultPath := Fixture.VaultStore.Config.VaultPath() - templateDir := Fixture.VaultStore.Config.TemplateDirectory() + templateDir := filepath.Join(Fixture.VaultStore.Config.VaultPath(), Fixture.VaultStore.Config.TemplateDirectory()) require.NoError(t, os.MkdirAll(templateDir, 0o755)) templatePath := filepath.Join(templateDir, "template.md") diff --git a/test/test_integration/main_test.go b/test/test_integration/main_test.go index 5af9bb8..ddda979 100644 --- a/test/test_integration/main_test.go +++ b/test/test_integration/main_test.go @@ -5,7 +5,6 @@ import ( "database/sql" "encoding/json" "os" - "path" "path/filepath" "testing" @@ -46,7 +45,7 @@ func NewDBFixture() *DBFixture { DB: dbContext.DB, DBPath: dbPath, TestContext: context.Background(), - VaultStore: store.NewVaultStore("testVault", vaultPath, path.Join(vaultPath, "templates"), []string{}, false, "", "", ""), + VaultStore: store.NewVaultStore("testVault", vaultPath, "templates", []string{}, false, "", "", ""), } }