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

fix: simplify the code for downloadInChunks #2323

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: simplify the code for downloadInChunks
  • Loading branch information
ddelgrosso1 committed Oct 8, 2023
commit 70e331136728afb76561caf70763b66ca82a7172
31 changes: 11 additions & 20 deletions src/transfer-manager.ts
Original file line number Diff line number Diff line change
@@ -665,26 +665,17 @@ export class TransferManager {
start += chunkSize;
}

return new Promise((resolve, reject) => {
let results: DownloadResponse;
Promise.all(promises)
.then(data => {
results = data.map(result => result.buffer) as DownloadResponse;
if (options.validation === 'crc32c') {
return CRC32C.fromFile(filePath);
}
return;
})
.then(() => {
resolve(results);
})
.catch(e => {
reject(e);
})
.finally(() => {
fileToWrite.close();
});
});
let results: DownloadResponse;
try {
const data = await Promise.all(promises);
results = data.map(result => result.buffer) as DownloadResponse;
if (options.validation === 'crc32c') {
await CRC32C.fromFile(filePath);
}
return results;
} finally {
fileToWrite.close();
}
}

/**