fix(page): fix AddPage not checking if the template actually existed.

This commit is contained in:
2026-05-27 23:07:08 +02:00
parent ae65322aa0
commit 664ae1f7d3
3 changed files with 32 additions and 7 deletions
+13
View File
@@ -15,6 +15,7 @@ const GETSPECIFICSVGSQL string = "SELECT * FROM svg WHERE id = ?;"
const GETSVGSQL string = "SELECT * FROM svg;"
const DELETESVGSQL string = "DELETE FROM svg WHERE id = ?;"
const RENAMESVGSQL string = "UPDATE svg SET name = ? WHERE id = ?;"
const EXISTSSVGSQL string = "SELECT COUNT(*) FROM svg WHERE id = ?;"
func InsertSVG(data *svg.TemplateData) error {
if _, err := database.Exec(INSERTSVGSQL, data.Id, data.Name); err != nil {
@@ -93,3 +94,15 @@ func RenameSvg(id string, name string) error {
}
return nil
}
func Exists(id string) (bool, error) {
res := database.QueryRow(EXISTSSVGSQL, id)
var count int
if err := res.Scan(&count); err != nil {
return false, err
}
return count > 0, nil
}