Report faulty index on connection or chunk error
This commit is contained in:
parent
c6dd2995f6
commit
c55e81f375
@ -365,7 +365,7 @@ class Reader:
|
|||||||
self.current_chunk = (-1, BytesIO())
|
self.current_chunk = (-1, BytesIO())
|
||||||
self.topics: dict[str, TopicInfo] = {}
|
self.topics: dict[str, TopicInfo] = {}
|
||||||
|
|
||||||
def open(self): # pylint: disable=too-many-branches,too-many-locals
|
def open(self): # pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||||
"""Open rosbag and read metadata."""
|
"""Open rosbag and read metadata."""
|
||||||
try:
|
try:
|
||||||
self.bio = self.path.open('rb')
|
self.bio = self.path.open('rb')
|
||||||
@ -402,8 +402,12 @@ class Reader:
|
|||||||
raise ReaderError('Bag is not indexed, reindex before reading.')
|
raise ReaderError('Bag is not indexed, reindex before reading.')
|
||||||
|
|
||||||
self.bio.seek(index_pos)
|
self.bio.seek(index_pos)
|
||||||
self.connections = dict(self.read_connection() for _ in range(conn_count))
|
try:
|
||||||
self.chunk_infos = [self.read_chunk_info() for _ in range(chunk_count)]
|
self.connections = dict(self.read_connection() for _ in range(conn_count))
|
||||||
|
self.chunk_infos = [self.read_chunk_info() for _ in range(chunk_count)]
|
||||||
|
except ReaderError as err:
|
||||||
|
raise ReaderError(f'Bag index looks damaged: {err.args}') from None
|
||||||
|
|
||||||
self.chunks = {}
|
self.chunks = {}
|
||||||
for chunk_info in self.chunk_infos:
|
for chunk_info in self.chunk_infos:
|
||||||
self.bio.seek(chunk_info.pos)
|
self.bio.seek(chunk_info.pos)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user