FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use a stream when uploading database contents by robertbrignull · Pull Request #1465 · github/codeql-action · GitHub

Use a stream when uploading database contents - #1465

Merged
robertbrignull merged 3 commits into
mainfrom
robertbrignull/upload_database_stream
Jan 9, 2023
Merged

robertbrignull merged 3 commits into
mainfrom
robertbrignull/upload_database_stream

Conversation

Copy link
Copy Markdown
Contributor

Closes #1383

Instead of loading the entire database contents into memory, pass a ReadStream to request. Internally, octokit uses node-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 to request.

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

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

robertbrignull requested a review from a team January 6, 2023 15:34
robertbrignull requested a review from a team as a code owner January 6, 2023 15:34

Copy link
Copy Markdown
Contributor Author

I tested this in another repo and the database upload was successful.

Copy link
Copy Markdown
Contributor

Hm, looks like there's a genuine unit test failure related to the Windows file system 👁️

Copy link
Copy Markdown
Contributor

Looks reasonable to me. @angelapwen is right. I wonder if you need to explicitly close the read stream before you can delete it.

robertbrignull changed the title Robertbrignull/upload database stream Use a stream when uploading database contents Jan 9, 2023
Comment thread src/database-upload.ts
Comment on lines +50 to +61
{
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

Outbound network request depends on [file data](1).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is intended and not changing behaviour in this PR

Copy link
Copy Markdown
Contributor Author

Thanks @angelapwen and @aeisenberg. I've added a finally block to close the stream. I'm glad we have those windows unit tests to catch this!

robertbrignull merged commit 166d98c into main Jan 9, 2023
robertbrignull deleted the robertbrignull/upload_database_stream branch January 9, 2023 12:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Support upload of large databases (> 2GB)

5 participants


Back | FazBrowse Home | New Git URL