Skip to content

Commit

Permalink
FMWK-604-xdr-restore-handler
Browse files Browse the repository at this point in the history
- working restore
  • Loading branch information
filkeith committed Jan 7, 2025
1 parent 86740a3 commit f66130c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion handler_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func newRestoreHandler[T models.TokenConstraint](
}

func (rh *RestoreHandler[T]) run() {
rh.errors = make(chan error, 1)
rh.stats.Start()

go doWork(rh.errors, rh.logger, func() error {
Expand Down
9 changes: 5 additions & 4 deletions io/encoding/asbx/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Decoder[T models.TokenConstraint] struct {
}

// NewDecoder creates a new Decoder that reads from the provided io.Reader.
func NewDecoder[T models.TokenConstraint](r io.Reader, fileNumber uint64) (*Decoder[T], error) {
func NewDecoder[T models.TokenConstraint](r io.Reader) (*Decoder[T], error) {
d := &Decoder[T]{
reader: r,
}
Expand All @@ -42,9 +42,10 @@ func NewDecoder[T models.TokenConstraint](r io.Reader, fileNumber uint64) (*Deco
return nil, fmt.Errorf("error reading asbx header: %w", err)
}

if d.fileNumber != fileNumber {
return nil, fmt.Errorf("file number mismatch got %d, want %d", fileNumber, d.fileNumber)
}
// TODO: make oreder check
// if d.fileNumber != fileNumber {
// return nil, fmt.Errorf("file number mismatch got %d, want %d", fileNumber, d.fileNumber)
// }

return d, nil
}
Expand Down
8 changes: 4 additions & 4 deletions io/encoding/asbx/encode_decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestEncoder_Decoder(t *testing.T) {

// Decode.
reader := bytes.NewReader(content)
dec, err := NewDecoder[*models.ASBXToken](reader, testFileNumber)
dec, err := NewDecoder[*models.ASBXToken](reader)
require.NoError(t, err)

nt, err := dec.NextToken()
Expand All @@ -89,7 +89,7 @@ func TestDecoder_ErrorHeader(t *testing.T) {
content := make([]byte, 0)

reader := bytes.NewReader(content)
_, err := NewDecoder[*models.ASBXToken](reader, testFileNumber)
_, err := NewDecoder[*models.ASBXToken](reader)
require.ErrorIs(t, err, io.EOF)
}

Expand All @@ -104,7 +104,7 @@ func TestDecoder_ErrorToken(t *testing.T) {
content = append(content, h...)

reader := bytes.NewReader(content)
dec, err := NewDecoder[*models.ASBXToken](reader, testFileNumber)
dec, err := NewDecoder[*models.ASBXToken](reader)
require.NoError(t, err)

_, err = dec.NextToken()
Expand All @@ -119,6 +119,6 @@ func TestDecoder_ErrorFileNumber(t *testing.T) {
content = append(content, h...)

reader := bytes.NewReader(content)
_, err := NewDecoder[*models.ASBXToken](reader, testFileNumber)
_, err := NewDecoder[*models.ASBXToken](reader)
require.Equal(t, "file number mismatch got 1, want 0", err.Error())
}
2 changes: 1 addition & 1 deletion io_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewDecoder[T models.TokenConstraint](eType EncoderType, src io.Reader) (Dec
return asb.NewDecoder[T](src)
case EncoderTypeASBX:
// TODO: pass file number.
return asbx.NewDecoder[T](src, 0)
return asbx.NewDecoder[T](src)
default:
return asb.NewDecoder[T](src)
}
Expand Down

0 comments on commit f66130c

Please sign in to comment.