From 6dcb57db45a83c94164ac6b4c0351c68db0dc004 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 7 Apr 2026 18:37:16 +0200 Subject: [PATCH] Fix blank path on new record creation Populate the Path field when creating notes via /new by constructing the expected filename and joining it with the denote directory. Default extension is .md. Also fix mutex lock/unlock to prevent crash. --- internal/p9/server/server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/p9/server/server.go b/internal/p9/server/server.go index 0d217a8..c41545b 100644 --- a/internal/p9/server/server.go +++ b/internal/p9/server/server.go @@ -605,15 +605,17 @@ func (s *server) dispatchWrite(f *fid, tag uint16) *plan9.Fcall { } } - identifier := time.Now().Format("20060102T150405") +identifier := time.Now().Format("20060102T150405") + fm := metadata.NewFrontMatter(title, signature, tags, identifier) + fileName := metadata.BuildFilename(fm, ".md") + path := filepath.Join(s.denoteDir, fileName) meta := &metadata.Metadata{ Identifier: identifier, Signature: signature, Title: title, Tags: tags, - Path: "", + Path: path, } - s.mu.Lock() s.notes = append(s.notes, meta) s.mu.Unlock() @@ -624,7 +626,6 @@ func (s *server) dispatchWrite(f *fid, tag uint16) *plan9.Fcall { return &plan9.Fcall{Type: plan9.Rwrite, Tag: fc.Tag, Count: uint32(len(f.writeBuf))} } - // Extract note identifier and field name from path parts := strings.Split(strings.Trim(f.path, "/"), "/") if len(parts) != 3 || parts[0] != "n" {