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: Add maxDownloadSize for artifact directory download #3232

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

tkyi
Copy link
Member

@tkyi tkyi commented Oct 29, 2024

Context

Would be nice if we could check for max file download size before downloading.

Objective

This PR adds config for maxDownloadSize for downloading artifact directories.

References

Related to #3227

License

I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@coveralls
Copy link

coveralls commented Oct 30, 2024

Coverage Status

coverage: 95.198% (-0.004%) from 95.202%
when pulling fcb5c76 on maxDownloadSize
into ffdfc1d on master.


// If total size exceeds allowed limit, stop further processing
if (totalSize > maxDownloadSize) {
throw new Error('Total size of files exceeds the allowed limit of 2GB.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Limit size in error message should not be hardcoded because limit download size is configurable.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

// Check file sizes by fetching metadata
for (const file of directoryArray) {
if (file) {
const fileMetaResponse = await request.head(`${baseUrl}/${file}?token=${token}&type=download`);
Copy link
Contributor

Choose a reason for hiding this comment

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

not pressing: for large no of files fetching metadata can be time consuming, we can run in parallel with a small batch size.

Copy link
Contributor

Choose a reason for hiding this comment

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

also, req.query.dir && req.query.type === 'download' , we may need schema validation for query params

Copy link
Member Author

Choose a reason for hiding this comment

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

pritamstyz4ever
pritamstyz4ever previously approved these changes Nov 1, 2024
Copy link
Contributor

@pritamstyz4ever pritamstyz4ever left a comment

Choose a reason for hiding this comment

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

minor comments, nothing urgent can be incorporated later.


// If total size exceeds allowed limit, stop further processing
if (totalSize > maxDownloadSize) {
throw new Error(`Total size of files exceeds the allowed limit of ${maxDownloadSize}GB.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't maxDownloadSize in bytes, not GB? I think it is needed to change the logging unit or convert it when outputting to the log.

@tkyi tkyi merged commit 03303f6 into master Nov 5, 2024
2 checks passed
@tkyi tkyi deleted the maxDownloadSize branch November 5, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants