Browse Source

Added check to see if template bundle file exists

Wirecog 6 years ago
parent
commit
bd31ec98b4
1 changed files with 15 additions and 13 deletions
  1. 15
    13
      templateset.go

+ 15
- 13
templateset.go View File

@@ -172,13 +172,8 @@ func (t *TemplateSet) RestoreTemplateBundleFromDisk() error {
172 172
 
173 173
 func (t *TemplateSet) GatherTemplates() {
174 174
 
175
-	if UseStaticTemplateBundleFile == true {
176
-		err := t.RestoreTemplateBundleFromDisk()
177
-		if err != nil {
178
-			log.Println("Detected initial run. Will generate a template bundle file.")
179
-		} else {
180
-			return
181
-		}
175
+	if UseStaticTemplateBundleFile == true && StaticTemplateBundleFileExists() == true {
176
+		return
182 177
 	}
183 178
 
184 179
 	bundle := NewTemplateBundle()
@@ -202,12 +197,8 @@ func (t *TemplateSet) GatherTemplates() {
202 197
 
203 198
 func (t *TemplateSet) GatherCogTemplates(cogTemplatePath string, prefixName string, templateFileExtension string) {
204 199
 
205
-	if UseStaticTemplateBundleFile == true {
206
-		if _, err := os.Stat(StaticTemplateBundleFilePath); os.IsNotExist(err) {
207
-			log.Println("Detected initial run. Will generate a template bundle file.")
208
-		} else {
209
-			return
210
-		}
200
+	if UseStaticTemplateBundleFile == true && StaticTemplateBundleFileExists() == true {
201
+		return
211 202
 	}
212 203
 
213 204
 	bundle := NewTemplateBundle()
@@ -228,3 +219,14 @@ func (t *TemplateSet) GatherCogTemplates(cogTemplatePath string, prefixName stri
228 219
 	}
229 220
 
230 221
 }
222
+
223
+func StaticTemplateBundleFileExists() bool {
224
+
225
+	if _, err := os.Stat(StaticTemplateBundleFilePath); os.IsNotExist(err) {
226
+
227
+		return false
228
+	} else {
229
+		return true
230
+	}
231
+
232
+}