Skip to content

Commit 1fea6c0

Browse files
authored
Fixed bug where ShareFileClient.download, ShareFileClient.downloadToBuffer or ShareFileClient.downloadToFile could corrupt data on retrying. (Azure#15604)
1 parent f9e6852 commit 1fea6c0

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

sdk/storage/storage-file-share/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 12.6.0 (2021-06-09)
44

55
- Updated Azure Storage Service API version to 2020-08-04.
6+
- Fixed bug where ShareFileClient.download, ShareFileClient.downloadToBuffer or ShareFileClient.downloadToFile could corrupt data if source is modified when retrying.
67

78
## 12.5.0 (2021-03-10)
89

sdk/storage/storage-file-share/src/Clients.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,14 +3579,17 @@ export class ShareFileClient extends StorageClient {
35793579
// }, options: ${JSON.stringify(updatedOptions)}`
35803580
// );
35813581

3582-
return (
3583-
await this.context.download({
3584-
abortSignal: options.abortSignal,
3585-
leaseAccessConditions: options.leaseAccessConditions,
3586-
...updatedOptions,
3587-
...convertTracingToRequestOptionsBase(updatedOptions)
3588-
})
3589-
).readableStreamBody!;
3582+
const downloadRes = await this.context.download({
3583+
abortSignal: options.abortSignal,
3584+
leaseAccessConditions: options.leaseAccessConditions,
3585+
...updatedOptions,
3586+
...convertTracingToRequestOptionsBase(updatedOptions)
3587+
});
3588+
3589+
if (!(downloadRes.etag === res.etag)) {
3590+
throw new Error("File has been modified concurrently");
3591+
}
3592+
return downloadRes.readableStreamBody!;
35903593
},
35913594
offset,
35923595
res.contentLength!,

0 commit comments

Comments
 (0)