diff pkg/controllers/srimports.go @ 1528:5874cedd7f91

Sounding result import: Accept *.txt files for XYZ data, too.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 07 Dec 2018 12:21:55 +0100
parents d753ce6cf588
children 24445a618513
line wrap: on
line diff
--- a/pkg/controllers/srimports.go	Fri Dec 07 11:21:16 2018 +0100
+++ b/pkg/controllers/srimports.go	Fri Dec 07 12:21:55 2018 +0100
@@ -217,12 +217,14 @@
 		Messages []string    `json:"messages,omitempty"`
 	}
 
-	var noXYZ bool
-	if noXYZ = common.FindInZIP(zr, ".xyz") == nil; noXYZ {
-		messages = append(messages, "no .xyz file found.")
+	find := func(ext string) *zip.File { return common.FindInZIP(zr, ext) }
+
+	noXYZ := find(".xyz") == nil && find(".txt") == nil
+	if noXYZ {
+		messages = append(messages, "no .xyz or .txt file found.")
 	}
 
-	if mj := common.FindInZIP(zr, "meta.json"); mj == nil {
+	if mj := find("meta.json"); mj == nil {
 		messages = append(messages, "no 'meta.json' file found.")
 	} else {
 		if meta, err := loadMeta(mj); err != nil {