From c59dc96d104babcdfc7e5302e5974dceb922a724 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Fri, 6 May 2022 10:31:41 -0700 Subject: [PATCH] refactor!: Misc cleanup (#1917) * test: disable resumable upload in acl test before (#1903) * build: Streamline `mocha` config (#1905) * build: Streamline `mocha` config * fix: Require `--require ts-node/register` first * refactor: Misc cleanup Co-authored-by: Denis DelGrosso <85250797+ddelgrosso1@users.noreply.github.com> --- package.json | 4 ++++ src/channel.ts | 7 ++----- src/file.ts | 18 +++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 634c33776..dadc884ad 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,10 @@ "google storage", "storage" ], + "mocha": { + "require": "ts-node/register", + "extension": "ts" + }, "scripts": { "predocs": "npm run compile", "docs": "jsdoc -c .jsdoc.js", diff --git a/src/channel.ts b/src/channel.ts index 8d62463b7..f0dff46dd 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -56,11 +56,8 @@ class Channel extends ServiceObject { super(config); - // TODO: remove type cast to any once ServiceObject's type declaration has - // been fixed. https://github.com/googleapis/nodejs-common/issues/176 - const metadata = this.metadata; - metadata.id = id; - metadata.resourceId = resourceId; + this.metadata.id = id; + this.metadata.resourceId = resourceId; } stop(): Promise; diff --git a/src/file.ts b/src/file.ts index aa1e1bc8a..15088ab72 100644 --- a/src/file.ts +++ b/src/file.ts @@ -401,13 +401,13 @@ export enum FileExceptionMessages { STARTS_WITH_TWO_ELEMENTS = 'StartsWith condition must be an array of 2 elements.', CONTENT_LENGTH_RANGE_MIN_MAX = 'ContentLengthRange must have numeric min & max fields.', DOWNLOAD_MISMATCH = 'The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.', - UPLOAD_MISMATCH_DELETE_FAIL = `The uploaded data did not match the data from the server. - As a precaution, we attempted to delete the file, but it was not successful. - To be sure the content is the same, you should try removing the file manually, - then uploading the file again. + UPLOAD_MISMATCH_DELETE_FAIL = `The uploaded data did not match the data from the server. + As a precaution, we attempted to delete the file, but it was not successful. + To be sure the content is the same, you should try removing the file manually, + then uploading the file again. \n\nThe delete attempt failed with this message:\n\n `, - UPLOAD_MISMATCH = `The uploaded data did not match the data from the server. - As a precaution, the file has been deleted. + UPLOAD_MISMATCH = `The uploaded data did not match the data from the server. + As a precaution, the file has been deleted. To be sure the content is the same, you should try uploading the file again.`, } @@ -1558,8 +1558,8 @@ class File extends ServiceObject { * `options.predefinedAcl = 'publicRead'`) * @property {string} [userProject] The ID of the project which will be * billed for the request. - * @property {string} [chunkSize] Create a separate request per chunk. Should - * be a multiple of 256 KiB (2^18). + * @property {string} [chunkSize] Create a separate request per chunk. This + * value is in bytes and should be a multiple of 256 KiB (2^18). * {@link https://cloud.google.com/storage/docs/performing-resumable-uploads#chunked-upload| We recommend using at least 8 MiB for the chunk size.} */ /** @@ -2030,7 +2030,7 @@ class File extends ServiceObject { if (destination) { fileStream.on('error', callback).once('data', data => { - // We know that the file exists the server + // We know that the file exists the server - now we can truncate/write to a file const writable = fs.createWriteStream(destination); writable.write(data); fileStream.pipe(writable).on('error', callback).on('finish', callback);