Skip to content

Commit

Permalink
seek before go routine
Browse files Browse the repository at this point in the history
  • Loading branch information
ofaurax committed Nov 10, 2023
1 parent 5361360 commit 9ab80e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 0 additions & 6 deletions providers/asrockrack/firmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func (a *ASRockRack) FirmwareInstallStatus(ctx context.Context, installVersion,
func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, fileSize int64) error {
var err error

mybytes, err := io.ReadAll(reader)
fmt.Printf("ReadAll reader before FRU len:%d\n", len(mybytes))

// 0. take the model so that we use a different endpoint on E3C256D4ID-NL
device := common.NewDevice()
device.Metadata = map[string]string{}
Expand All @@ -85,9 +82,6 @@ func (a *ASRockRack) firmwareInstallBMC(ctx context.Context, reader io.Reader, f
return errors.Wrap(err, "failed to get model in step 0/4")
}

mybytes, err = io.ReadAll(reader)
fmt.Printf("ReadAll reader afterFRU len:%d\n", len(mybytes))

// 1. set the device to flash mode - prepares the flash
// Beware: this locks some capabilities, e.g. the access to fruAttributes
a.log.V(2).WithValues("step", "1/4").Info("set device to flash mode, takes a minute...")
Expand Down
5 changes: 5 additions & 0 deletions providers/asrockrack/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ func (a *ASRockRack) uploadFirmware(ctx context.Context, endpoint string, fwRead
mybytes, err := io.ReadAll(fwReader)
fmt.Printf("ReadAll fwReader len:%d\n", len(mybytes))

if file, ok := fwReader.(*os.File); ok {
fmt.Printf("Seek before go routine\n")
file.Seek(0, 0)
}

// setup pipe
pipeReader, pipeWriter := io.Pipe()
defer pipeReader.Close()
Expand Down

0 comments on commit 9ab80e5

Please sign in to comment.