actually honor provided stdin/stdout

the BackupTar and RestoreTar functionality was ignoring provided
readers, which doesn't matter for real usage but breaks tests
by making them dump raw tar binaries to stdout.
This commit is contained in:
Seebs 2022-11-17 14:59:46 -06:00 committed by seebs
parent c681642734
commit 93153a97db
2 changed files with 6 additions and 5 deletions

View file

@ -127,7 +127,7 @@ func (cmd *BackupTarCommand) Run(ctx context.Context) (err error) {
// Create output file in temporary location, or send to stdout if a dash is specified.
var w io.Writer
if useStdout {
w = os.Stdout
w = cmd.Stdout
} else {
f, err := os.Create(cmd.OutputPath + ".tmp")
if err != nil {

View file

@ -73,16 +73,17 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) {
}
useStdin := cmd.Path == "-"
var f *os.File
var f io.Reader
// read from Stdin if path specified as -
if useStdin {
f = os.Stdin
f = cmd.Stdin
} else {
f, err = os.Open(cmd.Path)
file, err := os.Open(cmd.Path)
if err != nil {
return (err)
}
defer f.Close()
defer file.Close()
f = file
}
// Parse TLS configuration for node-specific clients.