From e9d7432e79be08ca2835f41e0c6f6341d0a7698d Mon Sep 17 00:00:00 2001 From: Jeffrey Frey Date: Tue, 29 Nov 2022 14:10:16 -0500 Subject: [PATCH] Fixup spacing Tabs, not spaces. --- internal/pkg/util/util.go | 94 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/internal/pkg/util/util.go b/internal/pkg/util/util.go index 5cc33d2a..62ac0c89 100644 --- a/internal/pkg/util/util.go +++ b/internal/pkg/util/util.go @@ -596,11 +596,11 @@ func FileGz( compressor, err := exec.LookPath("pigz") if err != nil { wwlog.Verbose("Could not locate PIGZ") - compressor, err := exec.LookPath("gzip") - if err != nil { - wwlog.Verbose("Could not locate GZIP") - return errors.Wrapf(err, "No compressor program for image file: %s", file_gz) - } + compressor, err := exec.LookPath("gzip") + if err != nil { + wwlog.Verbose("Could not locate GZIP") + return errors.Wrapf(err, "No compressor program for image file: %s", file_gz) + } } wwlog.Verbose("Using compressor program: %s", compressor) @@ -612,48 +612,48 @@ func FileGz( out, err := proc.CombinedOutput() if len(out) > 0 { - if err != nil && strings.HasSuffix(compressor, "gzip") && strings.Contains(out, "unrecognized option") { - /* Older version of gzip, try it another way: */ - wwlog.Verbose("%s does not recognize the --keep flag, trying piped stdout", compressor) - - /* Open the output file for writing: */ - gzippedFile, err := os.Create(file_gz) - if err != nil { - return errors.Wrapf(err, "Unable to open compressed image file for writing: %s", file_gz) - } - - /* We'll execute gzip with output to stdout and attach stdout to the compressed file we just - created: - */ - proc = exec.Command( - compressor, - "--stdout", - file ) - proc.Stdout = gzippedFile - gzipStderr, err := proc.StderrPipe() - if err != nil { - return errors.Wrapf(err, "Unable to open stderr pipe for compression program: %s", compressor) - } - - /* Execute the command: */ - err = proc.Start() - if err != nil { - proc.Wait() - gzippedFile.Close() - os.Remove(file_gz) - err = errors.Wrapf(err, "Unable to successfully execute compression program: %s", compressor) - } else { - err = proc.Wait() - gzippedFile.Close() - if err != nil { - os.Remove(file_gz) - err = errors.Wrapf(err, "Unable to successfully create compressed image file: %s", file_gz) - } else { - wwlog.Verbose("Successfully compressed image file: %s", file_gz) - } - } - out, _ = io.ReadAll(gzipStderr) - } + if err != nil && strings.HasSuffix(compressor, "gzip") && strings.Contains(out, "unrecognized option") { + /* Older version of gzip, try it another way: */ + wwlog.Verbose("%s does not recognize the --keep flag, trying piped stdout", compressor) + + /* Open the output file for writing: */ + gzippedFile, err := os.Create(file_gz) + if err != nil { + return errors.Wrapf(err, "Unable to open compressed image file for writing: %s", file_gz) + } + + /* We'll execute gzip with output to stdout and attach stdout to the compressed file we just + created: + */ + proc = exec.Command( + compressor, + "--stdout", + file ) + proc.Stdout = gzippedFile + gzipStderr, err := proc.StderrPipe() + if err != nil { + return errors.Wrapf(err, "Unable to open stderr pipe for compression program: %s", compressor) + } + + /* Execute the command: */ + err = proc.Start() + if err != nil { + proc.Wait() + gzippedFile.Close() + os.Remove(file_gz) + err = errors.Wrapf(err, "Unable to successfully execute compression program: %s", compressor) + } else { + err = proc.Wait() + gzippedFile.Close() + if err != nil { + os.Remove(file_gz) + err = errors.Wrapf(err, "Unable to successfully create compressed image file: %s", file_gz) + } else { + wwlog.Verbose("Successfully compressed image file: %s", file_gz) + } + } + out, _ = io.ReadAll(gzipStderr) + } wwlog.Debug(string(out)) }