use buffered reader to write to encryption mechanism

This commit is contained in:
Frederik Ring 2021-08-23 15:33:49 +02:00
parent ec87bd27e7
commit bf562ea71d

View File

@ -4,6 +4,7 @@
package main package main
import ( import (
"bufio"
"bytes" "bytes"
"context" "context"
"errors" "errors"
@ -275,11 +276,12 @@ func (s *script) encryptBackup() error {
return fmt.Errorf("encryptBackup: error encrypting backup file: %w", err) return fmt.Errorf("encryptBackup: error encrypting backup file: %w", err)
} }
b, err := ioutil.ReadFile(s.file) file, err := os.Open(s.file)
if err != nil { if err != nil {
return fmt.Errorf("encryptBackup: error opening unencrypted backup file: %w", err) return fmt.Errorf("encryptBackup: error opening backup file %s: %w", s.file, err)
} }
pt.Write(b) fileReader := bufio.NewReader(file)
fileReader.WriteTo(pt)
pt.Close() pt.Close()
gpgFile := fmt.Sprintf("%s.gpg", s.file) gpgFile := fmt.Sprintf("%s.gpg", s.file)