Skip to content

Commit

Permalink
dgraphtest is written to read gzipped schema file, extending the impl…
Browse files Browse the repository at this point in the history
…ementation to work with ASCII too.
  • Loading branch information
jbhamra1 committed Aug 23, 2023
1 parent effcdf0 commit 031aa56
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions dgraphtest/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,22 @@ func readGzData(r io.Reader, encryption bool) ([]byte, error) {
}
}

gr, err := gzip.NewReader(r)
if err != nil {
var rr io.Reader
if gr, err := gzip.NewReader(r); err != nil &&
strings.Contains(err.Error(), "gzip: invalid header") {
rr = r
} else if err != nil {
return nil, errors.Wrapf(err, "error creating gzip reader")
} else {
rr = gr
defer func() {
if err := gr.Close(); err != nil {
log.Printf("[WARNING] error closing gzip reader: %v", err)
}
}()
}
defer func() {
if err := gr.Close(); err != nil {
log.Printf("[WARNING] error closing gzip reader: %v", err)
}
}()

data, err := io.ReadAll(gr)
data, err := io.ReadAll(rr)
if err != nil {
return nil, errors.Wrap(err, "error reading data from io.Reader")
}
Expand Down

0 comments on commit 031aa56

Please sign in to comment.