Mercurial > gemma
changeset 3193:8329c6d3cf2a
Do not offer an import for review that did not import anything
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 08 May 2019 12:45:21 +0200 |
parents | cd076b7a2227 |
children | eeff2cc4ff9d |
files | pkg/imports/agm.go |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/agm.go Wed May 08 11:45:57 2019 +0200 +++ b/pkg/imports/agm.go Wed May 08 12:45:21 2019 +0200 @@ -326,11 +326,14 @@ checkedGauges := map[models.Isrs]bool{} lines: - for line := 1; ; line++ { + for line, ignored := 1, 0; ; line++ { row, err := r.Read() switch { case err == io.EOF || len(row) == 0: + if ignored == line-1 { + return nil, UnchangedError("No entries imported") + } break lines case err != nil: return nil, fmt.Errorf("CSV parsing failed: %v", err) @@ -345,6 +348,7 @@ if exists, found := checkedGauges[*gid]; found { if !exists { // Just ignore the line since we have already warned + ignored++ continue lines } } else { // not found in gauge cache @@ -361,6 +365,7 @@ checkedGauges[*gid] = exists if !exists { feedback.Warn("Ignoring data for unknown gauge %s", gid.String()) + ignored++ continue lines } }