Skip to content

Commit a83cbee

Browse files
authored
Merge pull request #9 from zweckj/0.0.17
Fix: catch missing field
2 parents eb0a6dc + f5f2808 commit a83cbee

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

onedrive_personal_sdk/clients/large_file_upload.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import asyncio
44
import logging
5+
from collections.abc import Awaitable, Callable
56
from datetime import datetime, timezone
6-
from collections.abc import Callable, Awaitable
77

88
from aiohttp import ClientSession
9+
from mashumaro.exceptions import MissingField
910

1011
from onedrive_personal_sdk.clients.base import OneDriveBaseClient
11-
from onedrive_personal_sdk.const import GRAPH_BASE_URL, HttpMethod, ConflictBehavior
12+
from onedrive_personal_sdk.const import GRAPH_BASE_URL, ConflictBehavior, HttpMethod
1213
from onedrive_personal_sdk.exceptions import (
14+
ExpectedRangeNotInBufferError,
1315
HashMismatchError,
1416
HttpRequestException,
1517
OneDriveException,
16-
ExpectedRangeNotInBufferError,
1718
UploadSessionExpired,
1819
)
1920
from onedrive_personal_sdk.models.items import File
@@ -84,8 +85,8 @@ async def upload(
8485
while retries < self._max_retries:
8586
try:
8687
return await self.start_upload(upload_session, validate_hash)
87-
except UploadSessionExpired:
88-
_LOGGER.debug("Session expired/not found, restarting")
88+
except (UploadSessionExpired, MissingField):
89+
_LOGGER.debug("Session expired/not found/broken, restarting")
8990
self._buffer = UploadBuffer()
9091
self._upload_result = LargeFileChunkUploadResult(
9192
datetime.now(timezone.utc), ["0-"]
@@ -131,8 +132,9 @@ async def start_upload(
131132
if self._buffer.length >= self._upload_chunk_size:
132133
uploaded_chunks = 0
133134
while (
134-
self._buffer.length - uploaded_chunks * UPLOAD_CHUNK_SIZE
135-
) > self._upload_chunk_size: # Loop in case the buffer is >= UPLOAD_CHUNK_SIZE * 2
135+
(self._buffer.length - uploaded_chunks * UPLOAD_CHUNK_SIZE)
136+
> self._upload_chunk_size
137+
): # Loop in case the buffer is >= UPLOAD_CHUNK_SIZE * 2
136138
slice_start = uploaded_chunks * self._upload_chunk_size
137139
try:
138140
chunk_result = await self._async_upload_chunk(

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.0.16"
3+
version = "0.0.17"
44
license = {text = "MIT"}
55
description = "A package to interact with the Microsoft Graph API for personal OneDrives."
66
readme = "README.md"

0 commit comments

Comments
 (0)