From 14f0c61c6e859cc88ec30ff5b0ed232e14d5357b Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 15 Mar 2022 20:38:29 +0100 Subject: [PATCH] =?UTF-8?q?Path=20probl=C3=A8me=20qui=20emp=C3=AAchait=20l?= =?UTF-8?q?a=20sauvegarde=20des=20fichiers=20dont=20la=20taille=20=C3=A9ta?= =?UTF-8?q?it=20inf=C3=A9rieur=20au=20BUFFER=20(1024)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/utils/FileReceiver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/utils/FileReceiver.go b/pkg/utils/FileReceiver.go index a966c03..a71da1a 100644 --- a/pkg/utils/FileReceiver.go +++ b/pkg/utils/FileReceiver.go @@ -15,7 +15,12 @@ func ReceiveFile(path string, fileSize int, reader *bufio.Reader) bool { defer file.Close() // Params - buffer := make([]byte, 1024) + var buffer []byte + if fileSize < 1024 { + buffer = make([]byte, fileSize) + } else { + buffer = make([]byte, 1024) + } currentSize := 0 // Copy file