comparison 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
comparison
equal deleted inserted replaced
1527:3cc3b7390805 1528:5874cedd7f91
215 Token string `json:"token,omitempty"` 215 Token string `json:"token,omitempty"`
216 Meta interface{} `json:"meta,omitempty"` 216 Meta interface{} `json:"meta,omitempty"`
217 Messages []string `json:"messages,omitempty"` 217 Messages []string `json:"messages,omitempty"`
218 } 218 }
219 219
220 var noXYZ bool 220 find := func(ext string) *zip.File { return common.FindInZIP(zr, ext) }
221 if noXYZ = common.FindInZIP(zr, ".xyz") == nil; noXYZ { 221
222 messages = append(messages, "no .xyz file found.") 222 noXYZ := find(".xyz") == nil && find(".txt") == nil
223 } 223 if noXYZ {
224 224 messages = append(messages, "no .xyz or .txt file found.")
225 if mj := common.FindInZIP(zr, "meta.json"); mj == nil { 225 }
226
227 if mj := find("meta.json"); mj == nil {
226 messages = append(messages, "no 'meta.json' file found.") 228 messages = append(messages, "no 'meta.json' file found.")
227 } else { 229 } else {
228 if meta, err := loadMeta(mj); err != nil { 230 if meta, err := loadMeta(mj); err != nil {
229 messages = append(messages, 231 messages = append(messages,
230 fmt.Sprintf("'meta.json' found but invalid: %v", err)) 232 fmt.Sprintf("'meta.json' found but invalid: %v", err))