diff --git a/cvat/apps/engine/media_extractors.py b/cvat/apps/engine/media_extractors.py index 0e37154db771..447e1d73a1e3 100644 --- a/cvat/apps/engine/media_extractors.py +++ b/cvat/apps/engine/media_extractors.py @@ -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: