Skip to content

Commit

Permalink
♻️ Remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 6, 2022
1 parent 7feef8d commit 215fa84
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,16 @@ func run(cmd *cobra.Command, args []string) (err error) {
// base64 is required since TTYs use CRLF
pr := base64.NewDecoder(base64.StdEncoding, pr)

switch conf.OutputFormat {
case sqlformat.Gzip, sqlformat.Custom:
_, err = io.Copy(io.MultiWriter(f, bar), pr)
case sqlformat.Plain:
var gzr *gzip.Reader
gzr, err = gzip.NewReader(pr)
if conf.OutputFormat == sqlformat.Plain {
pr, err = gzip.NewReader(pr)
if err != nil {
return
}
}

_, err = io.Copy(io.MultiWriter(f, bar), gzr)
if err != nil {
return
}
_, err = io.Copy(io.MultiWriter(f, bar), pr)
if err != nil {
return
}
}()

Expand Down

0 comments on commit 215fa84

Please sign in to comment.