fix(page): fix AddPage not checking if the template actually existed.
This commit is contained in:
@@ -2,6 +2,7 @@ package actions
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@@ -15,6 +16,17 @@ import (
|
||||
const FILEFORMAT string = "%s-%d"
|
||||
|
||||
func AddPage(id string, svgbuf []byte) (svg.TemplatePage, error) {
|
||||
|
||||
exists, err := database.Exists(id)
|
||||
|
||||
if err != nil {
|
||||
return svg.TemplatePage{}, err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
return svg.TemplatePage{}, errors.New("Template does not exist.")
|
||||
}
|
||||
|
||||
data := svg.TemplatePage{TemplateId: id}
|
||||
populateKeys(&data, svgbuf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user