Skip to content

Commit

Permalink
Close file
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Jun 13, 2023
1 parent c20e8fd commit a5e1f33
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cvat/apps/engine/media_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,14 @@ class ZipChunkWriter(IChunkWriter):

def _write_pcd_file(self, image):
image_buf = open(image, "rb") if isinstance(image, str) else image
properties = ValidateDimension.get_pcd_properties(image_buf)
w, h = int(properties["WIDTH"]), int(properties["HEIGHT"])
extension = self.POINT_CLOUD_EXT
image_buf.seek(0, 0)
image_buf = io.BytesIO(image_buf.read())
return image_buf, extension, w, h
try:
properties = ValidateDimension.get_pcd_properties(image_buf)
w, h = int(properties["WIDTH"]), int(properties["HEIGHT"])
image_buf.seek(0, 0)
return io.BytesIO(image_buf.read()), self.POINT_CLOUD_EXT, w, h
finally:
if isinstance(image, str):
image_buf.close()

def save_as_chunk(self, images, chunk_path):
with zipfile.ZipFile(chunk_path, 'x') as zip_chunk:
Expand Down

0 comments on commit a5e1f33

Please sign in to comment.