Skip to content

Commit

Permalink
[DataLake][Bug]Upload is not working with umask and permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
xiafu-msft committed Apr 22, 2020
1 parent bd99ea5 commit c6d3ccc
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def upload_data(self, data, # type: Union[AnyStr, Iterable[AnyStr], IO[AnyStr]]
:keyword ~azure.storage.filedatalake.DataLakeLeaseClient or str lease:
Required if the blob has an active lease. Value can be a DataLakeLeaseClient object
or the lease ID as a string.
:keyword str umaskoverwrite: Optional and only valid if Hierarchical Namespace is enabled for the account.
:keyword str umask: Optional and only valid if Hierarchical Namespace is enabled for the account.
When creating a file or directory and the parent folder does not have a default ACL,
the umask restricts the permissions of the file or directory to be created.
The resulting permission is given by p & ^u, where p is the permission and u is the umask.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,26 @@ def upload_datalake_file( # pylint: disable=unused-argument
if length == 0:
return {}
properties = kwargs.pop('properties', None)
umask = kwargs.pop('umask', None)
permissions = kwargs.pop('permissions', None)
path_http_headers = kwargs.pop('path_http_headers', None)
modified_access_conditions = kwargs.pop('modified_access_conditions', None)

if not overwrite:
# if customers didn't specify access conditions, they cannot flush data to existing file
if not _any_conditions(modified_access_conditions):
modified_access_conditions.if_none_match = '*'
if properties:
raise ValueError("metadata can be set only when overwrite is enabled")
if properties or umask or permissions:
raise ValueError("metadata, umask and permissions can be set only when overwrite is enabled")

if overwrite:
response = client.create(
resource='file',
path_http_headers=path_http_headers,
properties=properties,
modified_access_conditions=modified_access_conditions,
umask=umask,
permissions=permissions,
cls=return_response_headers,
**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,26 @@ async def upload_datalake_file( # pylint: disable=unused-argument
if length == 0:
return {}
properties = kwargs.pop('properties', None)
umask = kwargs.pop('umask', None)
permissions = kwargs.pop('permissions', None)
path_http_headers = kwargs.pop('path_http_headers', None)
modified_access_conditions = kwargs.pop('modified_access_conditions', None)

if not overwrite:
# if customers didn't specify access conditions, they cannot flush data to existing file
if not _any_conditions(modified_access_conditions):
modified_access_conditions.if_none_match = '*'
if properties:
raise ValueError("metadata can be set only when overwrite is enabled")
if properties or umask or permissions:
raise ValueError("metadata, umask and permissions can be set only when overwrite is enabled")

if overwrite:
response = await client.create(
resource='file',
path_http_headers=path_http_headers,
properties=properties,
modified_access_conditions=modified_access_conditions,
umask=umask,
permissions=permissions,
cls=return_response_headers,
**kwargs)

Expand Down
Loading

0 comments on commit c6d3ccc

Please sign in to comment.