From 7ab9fb7cec23dfbb76fc90367f908bd6c1fc8c4a Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 2 Jan 2025 18:53:14 +0530 Subject: [PATCH] simplify copy --- libs/filer/dbfs_client.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libs/filer/dbfs_client.go b/libs/filer/dbfs_client.go index c90814aa0..6a7f90600 100644 --- a/libs/filer/dbfs_client.go +++ b/libs/filer/dbfs_client.go @@ -167,18 +167,7 @@ func (w *DbfsClient) putFile(ctx context.Context, path string, overwrite bool, f pw.CloseWithError(fmt.Errorf("failed to write contents field in multipart form: %w", err)) return } - for { - // Copy the file in 10 MB chunks. This reduces the memory usage of the - // program when copying large files. - _, err := io.CopyN(contents, file, 10*1024*1024) - if err == io.EOF { - break - } - if err != nil { - pw.CloseWithError(fmt.Errorf("failed to copy file in multipart form: %w", err)) - return - } - } + _, err = io.Copy(contents, file) err = writer.Close() if err != nil { pw.CloseWithError(fmt.Errorf("failed to close multipart form writer: %w", err))