fix: keep default templates and plugins folder working

This commit is contained in:
2026-06-04 03:28:32 +08:00
parent 9d14ba50af
commit 58795b66b2
5 changed files with 74 additions and 2 deletions
+20
View File
@@ -231,6 +231,26 @@ func (a *App) OpenVaultFolder() error {
return cmd.Run()
}
func ensurePluginsFolder(vaultPath string) (string, error) {
path := filepath.Join(vaultPath, ".verstak", "plugins")
if err := os.MkdirAll(path, 0o750); err != nil {
return "", err
}
return path, nil
}
func (a *App) OpenPluginsFolder() error {
if !a.IsReady() {
return fmt.Errorf("vault not open")
}
target, err := ensurePluginsFolder(a.vault)
if err != nil {
return err
}
cmd := exec.Command("xdg-open", target)
return cmd.Run()
}
func (a *App) Search(query string) ([]SearchResultDTO, error) {
if err := a.requireVault(); err != nil {
return nil, err
+26
View File
@@ -0,0 +1,26 @@
package main
import (
"os"
"path/filepath"
"testing"
)
func TestEnsurePluginsFolder(t *testing.T) {
vault := t.TempDir()
path, err := ensurePluginsFolder(vault)
if err != nil {
t.Fatalf("ensurePluginsFolder: %v", err)
}
want := filepath.Join(vault, ".verstak", "plugins")
if path != want {
t.Fatalf("plugins path = %q, want %q", path, want)
}
if info, err := os.Stat(path); err != nil {
t.Fatalf("stat plugins dir: %v", err)
} else if !info.IsDir() {
t.Fatalf("plugins path is not a directory: %s", path)
}
}