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

@tus/s3-store: Don't download incomplete part on HEAD request #495

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

mitjap
Copy link
Collaborator

@mitjap mitjap commented Oct 19, 2023

Currently on every HEAD request entire incomplete part is downloaded to memory.

This PR makes HEAD request to S3 to determine incomplete part size.

@mitjap mitjap requested a review from Murderlon October 19, 2023 08:09
Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

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

Nice improvement!

return data.ContentLength
} catch (error) {
if (error instanceof NotFound) {
return undefined
Copy link
Member

@Murderlon Murderlon Oct 19, 2023

Choose a reason for hiding this comment

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

nit: when there is no incomplete part we can also consider the size 0. Especially if we want to always do addition on the return value.

Suggested change
return undefined
return 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking about that. In this case we would not be able to tell if there is no incomplete part or if its size is 0. For HEAD request that distinguishing is actually not needed. I'm good with both ways.

@Murderlon Murderlon merged commit 80dbbfa into tus:main Oct 19, 2023
3 checks passed
@mitjap mitjap deleted the s3-optimize-incomplete-part-size branch October 19, 2023 09:09
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.

2 participants