Skip to content

Commit

Permalink
incus/file/pull: Read files in chunks
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Feb 2, 2025
1 parent c06318b commit 04eab98
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/incus/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,17 @@ func (c *cmdFilePull) Run(cmd *cobra.Command, args []string) error {
return err
}
} else {
_, err = io.Copy(writer, src)
if err != nil {
progress.Done("")
return err
for {
// Read 1MB at a time.
_, err = io.CopyN(writer, src, 1024 * 1024 * 1024)

Check failure on line 691 in cmd/incus/file.go

View workflow job for this annotation

GitHub Actions / Code (oldstable)

File is not properly formatted (gci)

Check failure on line 691 in cmd/incus/file.go

View workflow job for this annotation

GitHub Actions / Code (stable)

File is not properly formatted (gci)
if err != nil {
if err == io.EOF {
break
}

progress.Done("")
return err
}
}
}

Expand Down

0 comments on commit 04eab98

Please sign in to comment.