-
Notifications
You must be signed in to change notification settings - Fork 357
Use a stream when uploading database contents #1465
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
Conversation
I tested this in another repo and the database upload was successful. |
Hm, looks like there's a genuine unit test failure related to the Windows file system 👁️ |
Looks reasonable to me. @angelapwen is right. I wonder if you need to explicitly close the read stream before you can delete it. |
{ | ||
owner: repositoryNwo.owner, | ||
repo: repositoryNwo.repo, | ||
language, | ||
name: `${language}-database`, | ||
data: bundledDbReadStream, | ||
headers: { | ||
authorization: `token ${apiDetails.auth}`, | ||
"Content-Type": "application/zip", | ||
"Content-Length": bundledDbSize, | ||
}, | ||
} |
Check warning
Code scanning / CodeQL
File data in outbound network request
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.
This is intended and not changing behaviour in this PR
Thanks @angelapwen and @aeisenberg. I've added a |
Closes #1383
Instead of loading the entire database contents into memory, pass a
ReadStream
torequest
. Internally, octokit usesnode-fetch
and that is capable of accepting a stream. I then had to add the content length manually because the database upload API requires this header, but it wasn't populated when passing a stream torequest
.Finally, I moved slightly more logic inside the try-catch. This should mean that if the database upload fails again for a user it won't block the main analysis and generally won't be an issue.
Merge / deployment checklist