add missing proper error return in WalkDir() (#18884)

without this the caller might end up returning
incorrect errors and not ignoring the drive
properly.
This commit is contained in:
Harshavardhana 2024-01-27 16:13:41 -08:00 committed by GitHub
parent 32e668eb94
commit 6347fb6636
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -407,12 +407,12 @@ func (client *storageRESTClient) WalkDir(ctx context.Context, opts WalkDirOption
opts.DiskID = client.diskID
b, err := opts.MarshalMsg(grid.GetByteBuffer()[:0])
if err != nil {
return err
return toStorageErr(err)
}
st, err := client.gridConn.NewStream(ctx, grid.HandlerWalkDir, b)
if err != nil {
return err
return toStorageErr(err)
}
return toStorageErr(st.Results(func(in []byte) error {
_, err := wr.Write(in)

View File

@ -87,6 +87,8 @@ func toStorageErr(err error) error {
switch err.Error() {
case errFaultyDisk.Error():
return errFaultyDisk
case errFaultyRemoteDisk.Error():
return errFaultyRemoteDisk
case errFileCorrupt.Error():
return errFileCorrupt
case errUnexpected.Error():
@ -135,6 +137,16 @@ func toStorageErr(err error) error {
return errDiskNotFound
case errDiskNotFound.Error():
return errDiskNotFound
case errMaxVersionsExceeded.Error():
return errMaxVersionsExceeded
case errInconsistentDisk.Error():
return errInconsistentDisk
case errDriveIsRoot.Error():
return errDriveIsRoot
case errDiskOngoingReq.Error():
return errDiskOngoingReq
case grid.ErrUnknownHandler.Error():
return errInconsistentDisk
}
return err
}