Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getProperties from ShareFileClient.downloadToFile() #32112

Closed

Conversation

ibrahimrabab
Copy link
Contributor

@ibrahimrabab ibrahimrabab commented Nov 11, 2022

Description

resolves #4527

Previously ShareFileAsyncClient.downloadToFile() made an unnecessary call of .getProperties().To avoid this, we are downloading using a single call to downloadWithResponse().

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Nov 11, 2022
@azure-sdk
Copy link
Collaborator

azure-sdk commented Nov 11, 2022

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-storage-file-share

@ibrahimrabab
Copy link
Contributor Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ibrahimrabab
Copy link
Contributor Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ibrahimrabab
Copy link
Contributor Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ibrahimrabab
Copy link
Contributor Author

/azp run java - storage - tests

@ibrahimrabab ibrahimrabab marked this pull request as ready for review November 23, 2022 21:04
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

headers.getCopySource(),
headers.getCopyStatus(),
headers.isServerEncrypted(),
null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor worry is customers who were using FileSmbProperties from download before will no longer have access to them.

ShareFileRange finalRange = range == null ? new ShareFileRange(0) : range;
return downloadWithResponse(new ShareFileDownloadOptions().setRange(finalRange)
.setRequestConditions(requestConditions), context)
.subscribeOn(Schedulers.boundedElastic())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the subscribeOn isn't necessary

private Mono<Response<ShareFileProperties>> downloadSingleChunk(AsynchronousFileChannel channel, ShareFileRange range,
ShareRequestConditions requestConditions, Context context) {
ShareFileRange finalRange = range == null ? new ShareFileRange(0) : range;
return downloadWithResponse(new ShareFileDownloadOptions().setRange(finalRange)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, this should get wrapped with FluxUtil.createRetriableDownloadFlux so the download can be resumed from a midpoint if it fails.

Comment on lines +977 to +979
.subscribeOn(Schedulers.boundedElastic())
.retryWhen(Retry.max(3).filter(throwable -> throwable instanceof IOException
|| throwable instanceof TimeoutException));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment where these aren't needed. We should let better retrying mechanisms handle this.

|| throwable instanceof TimeoutException))))
.then(Mono.just(response));

private static Mono<Void> writeBodyToFile(ShareFileDownloadAsyncResponse response, AsynchronousFileChannel channel,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to expose this through a new API, similar to what Blobs is doing where the Response type is something custom. Callers into the download without Response can call through this as well. That way we can offer a better choice but retain functionality of ShareFileProperties, and we won't need to add the translation code.

@jaschrep-msft
Copy link
Member

jaschrep-msft commented Nov 28, 2022

@ibrahimrabab removing getProperties on a method that returns ShareFileProperties makes me concerned that we are now failing to return certain values, especially when the issue was filed pre-12.0 and so we could make such changes. Have we validated there are no changes to response content?

@ibrahimrabab
Copy link
Contributor Author

Closing this PR since it is not possible to extract FileSmbProperties from the downloadWithResponse call. getProperties() call is needed to ensure we extract all relevant information needed by the user.

@ibrahimrabab ibrahimrabab deleted the downloadToFileRemoveProperties branch January 26, 2023 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove getProperties call for share file download to file
4 participants