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:
parent
5d6a94ef42
commit
6dcb57db45
|
|
@ -606,14 +606,16 @@ 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{
|
meta := &metadata.Metadata{
|
||||||
Identifier: identifier,
|
Identifier: identifier,
|
||||||
Signature: signature,
|
Signature: signature,
|
||||||
Title: title,
|
Title: title,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Path: "",
|
Path: path,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.notes = append(s.notes, meta)
|
s.notes = append(s.notes, meta)
|
||||||
s.mu.Unlock()
|
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))}
|
return &plan9.Fcall{Type: plan9.Rwrite, Tag: fc.Tag, Count: uint32(len(f.writeBuf))}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract note identifier and field name from path
|
// Extract note identifier and field name from path
|
||||||
parts := strings.Split(strings.Trim(f.path, "/"), "/")
|
parts := strings.Split(strings.Trim(f.path, "/"), "/")
|
||||||
if len(parts) != 3 || parts[0] != "n" {
|
if len(parts) != 3 || parts[0] != "n" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue