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.
This commit is contained in:
Levi Neely 2026-04-07 18:37:16 +02:00
parent 5d6a94ef42
commit 6dcb57db45
1 changed files with 5 additions and 4 deletions

View File

@ -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" {