Skip to content

Commit f2ef7aa

Browse files
committed
incus/file/pull: Read files in chunks
Signed-off-by: Stéphane Graber <[email protected]>
1 parent c06318b commit f2ef7aa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cmd/incus/file.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,17 @@ func (c *cmdFilePull) Run(cmd *cobra.Command, args []string) error {
686686
return err
687687
}
688688
} else {
689-
_, err = io.Copy(writer, src)
690-
if err != nil {
691-
progress.Done("")
692-
return err
689+
for {
690+
// Read 1MB at a time.
691+
_, err = io.CopyN(writer, src, 1024*1024*1024)
692+
if err != nil {
693+
if err == io.EOF {
694+
break
695+
}
696+
697+
progress.Done("")
698+
return err
699+
}
693700
}
694701
}
695702

0 commit comments

Comments
 (0)