From a9618f58d2053eafd2f51c3d4bb66a3b72424e70 Mon Sep 17 00:00:00 2001 From: Ivan Shcheklein Date: Wed, 3 Dec 2025 19:14:10 -0800 Subject: [PATCH] capture version_id after upload --- adlfs/spec.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/adlfs/spec.py b/adlfs/spec.py index 3aaf5f9e..1f22cf63 100644 --- a/adlfs/spec.py +++ b/adlfs/spec.py @@ -2233,9 +2233,10 @@ async def _async_upload_chunk(self, final: bool = False, **kwargs): async with self.container_client.get_blob_client( blob=self.blob ) as bc: - await bc.commit_block_list( + response = await bc.commit_block_list( block_list=block_list, metadata=self.metadata, **commit_kw ) + self.version_id = response.get("version_id") except ResourceExistsError as e: raise FileExistsError(self.path) from e except Exception as e: @@ -2247,11 +2248,12 @@ async def _async_upload_chunk(self, final: bool = False, **kwargs): async with self.container_client.get_blob_client( blob=self.blob ) as bc: - await bc.upload_blob( + response = await bc.upload_blob( data=data, metadata=self.metadata, overwrite=(self.mode == "wb"), ) + self.version_id = response.get("version_id") elif length == 0 and final: # just finalize block_list = [BlobBlock(_id) for _id in self._block_list] @@ -2259,23 +2261,25 @@ async def _async_upload_chunk(self, final: bool = False, **kwargs): blob=self.blob ) as bc: try: - await bc.commit_block_list( + response = await bc.commit_block_list( block_list=block_list, metadata=self.metadata, **commit_kw, ) + self.version_id = response.get("version_id") except ResourceExistsError: raise FileExistsError(self.path) else: raise RuntimeError(f"Failed to upload block: {e}!") from e elif self.mode == "ab": async with self.container_client.get_blob_client(blob=self.blob) as bc: - await bc.upload_blob( + response = await bc.upload_blob( data=data, length=length, blob_type=BlobType.AppendBlob, metadata=self.metadata, ) + self.version_id = response.get("version_id") else: raise ValueError( "File operation modes other than wb, xb or ab are not supported for upload_chunk"