From d158c2776e2761ad5c67cc4088b126f519ffad64 Mon Sep 17 00:00:00 2001 From: Andreas Baulig Date: Wed, 18 Aug 2021 20:56:32 +0000 Subject: [PATCH] Fix writing miscellaneous bytes after EOF --- rescuesdriq/rescuesdriq.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rescuesdriq/rescuesdriq.go b/rescuesdriq/rescuesdriq.go index 7bcc86e0b..39b3b86d0 100644 --- a/rescuesdriq/rescuesdriq.go +++ b/rescuesdriq/rescuesdriq.go @@ -84,18 +84,15 @@ func copyContent(reader *bufio.Reader, writer *bufio.Writer, blockSize uint) { for { n, err := reader.Read(p) - if err != nil { + if err == nil || err == io.EOF { + writer.Write(p[0:n]) + sz += int64(n) if err == io.EOF { - writer.Write(p[0:n]) - sz += int64(n) - break - } else { - fmt.Println("An error occurred during content copy. Aborting") break } } else { - writer.Write(p) - sz += int64(blockSize) * 4096 + fmt.Println("An error occurred during content copy. Aborting") + break } fmt.Printf("Wrote %d bytes\r", sz)