Skip to content

Commit

Permalink
incusd/storage/drivers/vfs: Use SparseFileWrapper on backup import
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Ilaiwi <burkmoh@gmail.com>
  • Loading branch information
milaiwi committed Apr 20, 2024
1 parent ac65332 commit ce9368d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/server/storage/drivers/generic_vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ func genericVFSBackupUnpack(d Driver, sysOS *sys.OS, vol Volume, snapshots []str

// Open block file (use O_CREATE to support drivers that use image files).
to, err := os.OpenFile(targetPath, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
customWrapper := &SparseFileWrapper{W: to}
if err != nil {
return fmt.Errorf("Error opening file for writing %q: %w", targetPath, err)
}
Expand All @@ -786,7 +787,7 @@ func genericVFSBackupUnpack(d Driver, sysOS *sys.OS, vol Volume, snapshots []str
}

d.Logger().Debug(logMsg, logger.Ctx{"source": srcFile, "target": targetPath})
_, err = io.Copy(to, tr)
_, err = io.Copy(customWrapper, tr)
if err != nil {
return err
}
Expand Down

0 comments on commit ce9368d

Please sign in to comment.