Skip to content

Commit

Permalink
rollback importer defer, bring pw.Close() to closure
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed May 1, 2024
1 parent 9995356 commit b6c8dbe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions store/commitment/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ loop:
if err != nil {
return snapshotstypes.SnapshotItem{}, fmt.Errorf("failed to import tree for version %d: %w", version, err)
}
defer importer.Close()

case *snapshotstypes.SnapshotItem_IAVL:
if importer == nil {
Expand Down Expand Up @@ -461,10 +462,6 @@ loop:
}
}

if err := importer.Close(); err != nil {
return snapshotstypes.SnapshotItem{}, fmt.Errorf("failed to close importer: %w", err)
}

return snapshotItem, c.LoadVersion(version)
}

Expand Down
2 changes: 1 addition & 1 deletion store/snapshots/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ func (s *Store) Load(height uint64, format uint32) (*types.Snapshot, <-chan io.R
if _, err := io.Copy(pw, chunk); err != nil {
return fmt.Errorf("failed to copy chunk %d: %w", i, err)
}
_ = pw.Close()
return nil
}()
if err != nil {
_ = pw.CloseWithError(err)
return
}
_ = pw.Close()
}
}()

Expand Down

0 comments on commit b6c8dbe

Please sign in to comment.