Skip to content

Commit 6ce923c

Browse files
Use a stream when uploading database contents
1 parent ff3337e commit 6ce923c

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

lib/database-upload.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/database-upload.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/database-upload.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export async function uploadDatabases(
4040
// Although we are uploading arbitrary file contents to the API, it's worth
4141
// noting that it's the API's job to validate that the contents is acceptable.
4242
// This API method is available to anyone with write access to the repo.
43-
const payload = fs.readFileSync(
44-
await bundleDb(config, language, codeql, language)
45-
);
43+
const bundledDb = await bundleDb(config, language, codeql, language);
4644
try {
4745
await client.request(
4846
`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`,
@@ -51,10 +49,11 @@ export async function uploadDatabases(
5149
repo: repositoryNwo.repo,
5250
language,
5351
name: `${language}-database`,
54-
data: payload,
52+
data: fs.createReadStream(bundledDb),
5553
headers: {
5654
authorization: `token ${apiDetails.auth}`,
5755
"Content-Type": "application/zip",
56+
"Content-Length": fs.statSync(bundledDb).size,
5857
},
5958
}
6059
);

0 commit comments

Comments
 (0)