Skip to content

Commit 4f53b81

Browse files
authored
Merge pull request #24 from zweckj/fix/byte-counting
bugfixes
2 parents 62cc949 + fd5f66d commit 4f53b81

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

onedrive_personal_sdk/clients/large_file_upload.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ async def start_upload(
154154
retries = 0
155155
quick_xor_hash = QuickXorHash()
156156
result = {}
157+
total_uploaded_bytes = 0
158+
total_progress_bytes = 0
157159

158160
async for chunk in self._file.content_stream:
159161
self._buffer.buffer += chunk
@@ -168,7 +170,6 @@ async def start_upload(
168170
total_uploaded_bytes : total_uploaded_bytes
169171
+ current_chunk_size
170172
]
171-
quick_xor_hash.update(chunk_view)
172173
try:
173174
chunk_result = await self._async_upload_chunk(
174175
upload_session.upload_url,
@@ -250,6 +251,7 @@ async def start_upload(
250251
await asyncio.sleep(2**retries)
251252
continue
252253
else:
254+
quick_xor_hash.update(chunk_view)
253255
if "file" in chunk_result: # last chunk, no more ranges
254256
result = chunk_result
255257
else:
@@ -265,8 +267,9 @@ async def start_upload(
265267
retries = 0
266268
self._start += current_chunk_size
267269
total_uploaded_bytes += current_chunk_size
270+
total_progress_bytes += current_chunk_size
268271
if self._progress_callback:
269-
self._progress_callback(total_uploaded_bytes)
272+
self._progress_callback(total_progress_bytes)
270273

271274
# returned range is not what we expected, fix range
272275
if self._start != (
@@ -292,9 +295,9 @@ async def start_upload(
292295
self._buffer.buffer,
293296
)
294297
self._start += self._buffer.length
295-
total_uploaded_bytes += self._buffer.length
298+
total_progress_bytes += self._buffer.length
296299
if self._progress_callback:
297-
self._progress_callback(total_uploaded_bytes)
300+
self._progress_callback(total_progress_bytes)
298301
# except APIError:
299302
# await self._commit_file(upload_session)
300303

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "onedrive-personal-sdk"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
license = "MIT"
55
description = "A package to interact with the Microsoft Graph API for personal OneDrives."
66
readme = "README.md"

0 commit comments

Comments
 (0)