Skip to content

Commit b7ecd39

Browse files
committed
fix: override ServiceOperationPath.delimiter to prevent double slash when parent is UrlPath
1 parent 7c0dce9 commit b7ecd39

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

office365/onedrive/driveitems/uploadable_properties.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4+
from typing import Optional, Dict, Any
45

56
from office365.onedrive.driveitems.source import DriveItemSource
67
from office365.onedrive.files.system_info import FileSystemInfo
78
from office365.onedrive.media_source import MediaSource
89
from office365.runtime.client_value import ClientValue
10+
from office365.runtime.odata.json_format import ODataJsonFormat
911

1012

1113
@dataclass
@@ -25,6 +27,12 @@ def file_size(self):
2527
"""Provides an expected file size to perform a quota check prior to upload. Only on OneDrive Personal."""
2628
return self._fileSize
2729

30+
def to_json(self, json_format: Optional[ODataJsonFormat] = None) -> Dict[str, Any]:
31+
payload = super().to_json(json_format)
32+
payload.pop("driveItemSource", None)
33+
payload.pop("mediaSource", None)
34+
return payload
35+
2836
@property
2937
def entity_type_name(self) -> str:
30-
return "microsoft.graph.DriveItemUploadableProperties"
38+
return None # type: ignore

office365/runtime/client_value.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def _is_valid_value(val):
7676
return False
7777
elif isinstance(val, ClientValueCollection) and len(val) == 0:
7878
return False
79+
elif isinstance(val, ClientValue):
80+
if not any(v is not None for v in vars(val).values()):
81+
return False
7982
return True
8083

8184
result = {k: v for k, v in self if _is_valid_value(v)}

office365/runtime/paths/service_operation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def __init__(
2929
super().__init__(name, parent)
3030
self._parameters = parameters
3131

32+
@property
33+
def delimiter(self):
34+
from office365.onedrive.internal.paths.url import UrlPath
35+
36+
if isinstance(self.parent, UrlPath):
37+
return ""
38+
return "/"
39+
3240
@property
3341
def segment(self) -> str:
3442
"""Gets the OData path segment for this service operation."""

0 commit comments

Comments
 (0)