Do not read index if no chunks in rosbag1

This commit is contained in:
Marko Durkovic 2023-03-02 12:25:05 +01:00
parent 967328627c
commit 9830c38fc7

View File

@ -357,7 +357,7 @@ class Reader:
self.bio: Optional[BinaryIO] = None
self.connections: list[Connection] = []
self.indexes: dict[int, list[IndexData]]
self.indexes: dict[int, list[IndexData]] = {}
self.index_data_header_offsets: Optional[tuple[int, int]] = None
self.chunk_infos: list[ChunkInfo] = []
self.chunks: dict[int, Chunk] = {}
@ -397,6 +397,9 @@ class Reader:
if index_pos == 0:
raise ReaderError('Bag is not indexed, reindex before reading.')
if chunk_count == 0:
return
self.bio.seek(index_pos)
try:
self.connections = [self.read_connection() for _ in range(conn_count)]