Improve logging and errors
This commit is contained in:
parent
64d6b05514
commit
04fa3afc67
9
file.go
9
file.go
|
@ -34,7 +34,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/blevesearch/bleve"
|
"github.com/blevesearch/bleve"
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -184,6 +183,7 @@ func (fp *FilePages) Get(name string) Page {
|
||||||
|
|
||||||
page, err := fp.oldPagesBackend(name)
|
page, err := fp.oldPagesBackend(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("Deprecated:", err)
|
||||||
return fp.blocksBackendGet(name, BlockResponse{ParentID: "root", PageID: name}, to)
|
return fp.blocksBackendGet(name, BlockResponse{ParentID: "root", PageID: name}, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,25 +241,23 @@ func (fp *FilePages) oldPagesBackend(title string) (Page, error) {
|
||||||
|
|
||||||
f, err := os.Open(filepath.Join(fp.dirname, name))
|
f, err := os.Open(filepath.Join(fp.dirname, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("while opening file in oldPagesBackend: %s", err)
|
|
||||||
return Page{
|
return Page{
|
||||||
Title: title,
|
Title: title,
|
||||||
Name: name,
|
Name: name,
|
||||||
Content: "",
|
Content: "",
|
||||||
Refs: refs,
|
Refs: refs,
|
||||||
}, err
|
}, fmt.Errorf("in old pages backend: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
body, err := ioutil.ReadAll(f)
|
body, err := ioutil.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("while reading file in oldPagesBackend: %s", err)
|
|
||||||
return Page{
|
return Page{
|
||||||
Name: name,
|
Name: name,
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: "",
|
Content: "",
|
||||||
Refs: refs,
|
Refs: refs,
|
||||||
}, err
|
}, fmt.Errorf("while reading %q in old pages backend: %w", name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Page{
|
return Page{
|
||||||
|
@ -289,7 +287,6 @@ func (fp *FilePages) save(msg saveMessage) error {
|
||||||
page.Name = p
|
page.Name = p
|
||||||
page.Title = p
|
page.Title = p
|
||||||
}
|
}
|
||||||
spew.Dump(page)
|
|
||||||
|
|
||||||
sw.Start("create blocks")
|
sw.Start("create blocks")
|
||||||
err := saveBlocksFromPage(fp.dirname, page)
|
err := saveBlocksFromPage(fp.dirname, page)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user