template path fix (#48)
This commit is contained in:
parent
a21ff37225
commit
4025f03826
4 changed files with 9 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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, "", "", ""),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue