Skip to content

Commit

Permalink
Fix incorrect record count in the importer
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jul 5, 2020
1 parent e7da8fa commit b45a2a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/views/Import.vue
Expand Up @@ -284,7 +284,7 @@ export default Vue.extend({
// Import progress bar value.
progress() {
if (!this.status) {
if (!this.status || !this.status.total > 0) {
return 0;
}
return Math.ceil((this.status.imported / this.status.total) * 100);
Expand Down
8 changes: 7 additions & 1 deletion internal/subimporter/importer.go
Expand Up @@ -432,8 +432,14 @@ func (s *Session) LoadCSV(srcPath string, delim rune) error {
s.log.Printf("error counting lines in '%s': '%v'", srcPath, err)
return err
}

if numLines == 0 {
return errors.New("empty file")
}

s.im.Lock()
s.im.status.Total = numLines
// Exclude the header from count.
s.im.status.Total = numLines - 1
s.im.Unlock()

// Rewind, now that we've done a linecount on the same handler.
Expand Down

0 comments on commit b45a2a0

Please sign in to comment.