-
Notifications
You must be signed in to change notification settings - Fork 169
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
Conversation
plugins/builds/artifacts/get.js
Outdated
|
||
// 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.'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schema validation should already exist for those params
https://github.com/screwdriver-cd/screwdriver/blob/master/plugins/builds/artifacts/get.js#L171-L172
There was a problem hiding this 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.
plugins/builds/artifacts/get.js
Outdated
|
||
// 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.`); |
There was a problem hiding this comment.
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.
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.