Skip to content

Commit

Permalink
chore: fix type errors in build (#2577)
Browse files Browse the repository at this point in the history
* chore: fix type errors in build

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix docs links

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
ddelgrosso1 and gcf-owl-bot[bot] authored Feb 11, 2025
1 parent 75c309c commit 86f77ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "storage",
"name_pretty": "Google Cloud Storage",
"product_documentation": "https://cloud.google.com/storage",
"client_documentation": "https://googleapis.dev/nodejs/storage/latest",
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/storage/latest",
"issue_tracker": "https://issuetracker.google.com/savedsearches/559782",
"release_level": "stable",
"language": "nodejs",
Expand Down
12 changes: 9 additions & 3 deletions src/crc32c.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,16 @@ class CRC32C implements CRC32CValidator {
static async fromFile(file: PathLike) {
const crc32c = new CRC32C();

await new Promise((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
createReadStream(file)
.on('data', (d: Buffer) => crc32c.update(d))
.on('end', resolve)
.on('data', (d: string | Buffer) => {
if (typeof d === 'string') {
crc32c.update(Buffer.from(d));
} else {
crc32c.update(d);
}
})
.on('end', () => resolve())
.on('error', reject);
});

Expand Down
8 changes: 6 additions & 2 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2310,8 +2310,12 @@ class File extends ServiceObject<File, FileMetadata> {
writable.write(data);
fileStream
.pipe(writable)
.on('error', callback)
.on('finish', callback);
.on('error', (err: Error) => {
callback(err, Buffer.from(''));
})
.on('finish', () => {
callback(null, data);
});
})
.on('end', () => {
// In the case of an empty file no data will be received before the end event fires
Expand Down
4 changes: 2 additions & 2 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ describe('storage', function () {

const file = bucket.file(filename);

await new Promise((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
file
.createReadStream()
.on('error', reject)
Expand All @@ -2578,7 +2578,7 @@ describe('storage', function () {
})
.pipe(fs.createWriteStream(tmpFilePath))
.on('error', reject)
.on('finish', resolve);
.on('finish', () => resolve());
});

await file.delete();
Expand Down

0 comments on commit 86f77ce

Please sign in to comment.