Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions adlfs/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -2247,35 +2248,38 @@ 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]
async with self.container_client.get_blob_client(
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"
Expand Down