From 9df029453b5580b1c35f695064a32d7324e7f182 Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Thu, 18 Jul 2024 14:23:55 +0300 Subject: [PATCH] db.get err --- main.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 7da215a..0b11463 100644 --- a/main.go +++ b/main.go @@ -236,6 +236,18 @@ func renderIndex(w gemini.ResponseWriter, client TreeManagerClient) { return } + lastRebuild, found := db.Get("last_rebuild") + if !found { + w.WriteHeader(gemini.StatusTemporaryFailure, "Internal server error") + return + } + + pageCounter, found := db.Get("page_counter") + if !found { + w.WriteHeader(gemini.StatusTemporaryFailure, "Internal server error") + return + } + w.SetMediaType("text/gemini") tpl := pongo2.Must(pongo2.FromFile(fmt.Sprintf("templates/%s/index.gmi", defaultLang))) page, err := tpl.Execute( @@ -243,8 +255,8 @@ func renderIndex(w gemini.ResponseWriter, client TreeManagerClient) { "tree": tree, "lang": defaultLang, "lastFiles": GetLastFiles(tree.Files), - "lastRebuild": db.Get("last_rebuild"), - "pageCounter": db.Get("page_counter"), + "lastRebuild": lastRebuild, + "pageCounter": pageCounter, }, ) if err != nil {