summary refs log tree commit diff stats
path: root/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/cache.go b/cache.go
index 2ed21f3..214d185 100644
--- a/cache.go
+++ b/cache.go
@@ -1,8 +1,10 @@
 package main
 
 import (
+	"io/ioutil"
 	"log"
 	"net"
+	"os"
 	"strings"
 	"time"
 
@@ -185,3 +187,52 @@ func pullDatabase() {
 		log.Printf("Error while pulling DB into registry cache: %v\n", err)
 	}
 }
+
+// pingAssets checks if the local static assets
+// need to be re-cached. If they do, they are
+// pulled back into memory from disk.
+func pingAssets() {
+
+	cssStat, err := os.Stat("assets/style.css")
+	if err != nil {
+		log.Printf("%v\n", err)
+	}
+	/*
+		indexStat, err := os.Stat("assets/tmpl/index.html")
+		if err != nil {
+			log.Printf("%v\n", err)
+		}
+
+		indexMod := staticCache.indexMod*/
+	cssMod := staticCache.cssMod
+	/*
+		if !indexMod.Equal(indexStat.ModTime()) {
+			var err error
+			tmpls, err = template.ParseFiles("assets/tmpl/index.html")
+			if err != nil {
+				log.Printf("%v\n", err)
+			}
+			buf := bytes.NewBuffer(staticCache.index)
+
+			confObj.Mu.RLock()
+			err = tmpls.ExecuteTemplate(buf, "index.html", confObj.Instance)
+			confObj.Mu.RUnlock()
+			if err != nil {
+				log.Printf("%v\n", err)
+			}
+
+			staticCache.index = buf.Bytes()
+			staticCache.indexMod = indexStat.ModTime()
+		}
+	*/
+	if !cssMod.Equal(cssStat.ModTime()) {
+
+		css, err := ioutil.ReadFile("assets/style.css")
+		if err != nil {
+			log.Printf("%v\n", err)
+		}
+
+		staticCache.css = css
+		staticCache.cssMod = cssStat.ModTime()
+	}
+}
pre>12
13
14
15