From bf562ea71dcf38c31513dce3407c83db569d9121 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Mon, 23 Aug 2021 15:33:49 +0200 Subject: [PATCH] use buffered reader to write to encryption mechanism --- cmd/backup/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/backup/main.go b/cmd/backup/main.go index b83f0bd..0c777ea 100644 --- a/cmd/backup/main.go +++ b/cmd/backup/main.go @@ -4,6 +4,7 @@ package main import ( + "bufio" "bytes" "context" "errors" @@ -275,11 +276,12 @@ func (s *script) encryptBackup() error { 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 { - 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() gpgFile := fmt.Sprintf("%s.gpg", s.file)