diff --git a/connect.go b/connect.go index 7e28fe88..3789945c 100644 --- a/connect.go +++ b/connect.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "encoding/hex" "encoding/json" "fmt" @@ -370,7 +369,15 @@ func (c *Connection) sendFile(id int, connection net.Conn) { connection.Write([]byte(fillString(strconv.FormatInt(int64(chunkSize), 10), 10))) sendBuffer := make([]byte, BUFFERSIZE) - file := bytes.NewBuffer(c.File.bytes) + + // open encrypted file + file, err := os.Open(c.File.Name + ".enc") + if err != nil { + log.Error(err) + return + } + defer file.Close() + chunkI := 0 if !c.Debug { c.bars[id] = uiprogress.AddBar(chunksPerWorker).AppendCompleted().PrependElapsed() diff --git a/crypto_test.go b/crypto_test.go index c475d5ba..5a8f4f97 100644 --- a/crypto_test.go +++ b/crypto_test.go @@ -45,5 +45,4 @@ func TestEncryptFiles(t *testing.T) { } os.Remove("temp.dec") os.Remove("temp.enc") - }