Skip to content

Commit

Permalink
Fixing the error due to mixing of gzip and plain text io.Readers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbhamra1 committed Aug 24, 2023
1 parent 031aa56 commit c99cef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 10 additions & 4 deletions dgraphtest/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func readGzFile(sf string, encryption bool) ([]byte, error) {
}
}()

data, err := readGzData(fd, encryption)
data, err := readGzData(fd, sf, encryption)
if err != nil {
return nil, errors.Wrapf(err, "error reading data from file [%v]", sf)
}
return data, nil
}

func readGzData(r io.Reader, encryption bool) ([]byte, error) {
func readGzData(r io.Reader, sf string, encryption bool) ([]byte, error) {
if encryption {
encKey, err := os.ReadFile(encKeyPath)
if err != nil {
Expand All @@ -83,7 +83,13 @@ func readGzData(r io.Reader, encryption bool) ([]byte, error) {
var rr io.Reader
if gr, err := gzip.NewReader(r); err != nil &&
strings.Contains(err.Error(), "gzip: invalid header") {
rr = r
if len(sf) > 0 {
if rr, err = os.Open(sf); err != nil {
return nil, errors.Wrapf(err, "error opening file")
}
} else if len(sf) == 0 {
return nil, errors.Wrapf(err, "error creating gzip reader")
}
} else if err != nil {
return nil, errors.Wrapf(err, "error creating gzip reader")
} else {
Expand Down Expand Up @@ -311,7 +317,7 @@ func modifyACLEntries(c *LocalCluster, r io.Reader) (io.Reader, error) {
grootUIDNew = fmt.Sprintf("<%v>", grootUIDNew)
guardiansUIDNew = fmt.Sprintf("<%v>", guardiansUIDNew)

data, err := readGzData(r, c.conf.encryption)
data, err := readGzData(r, "", c.conf.encryption)
if err != nil {
return nil, err
}
Expand Down
6 changes: 1 addition & 5 deletions systest/21million/bulk/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,5 @@ func (bsuite *BulkTestSuite) bulkLoader() error {
}

func (lsuite *BulkTestSuite) StartAlpha() error {
c := lsuite.lc
if err := c.Start(); err != nil {
return err
}
return c.HealthCheck(false)
return lsuite.lc.Start()
}

0 comments on commit c99cef0

Please sign in to comment.