Skip to content

Commit

Permalink
refactor!: Misc cleanup (googleapis#1917)
Browse files Browse the repository at this point in the history
* test: disable resumable upload in acl test before (googleapis#1903)

* build: Streamline `mocha` config (googleapis#1905)

* build: Streamline `mocha` config

* fix: Require `--require ts-node/register` first

* refactor: Misc cleanup

Co-authored-by: Denis DelGrosso <[email protected]>
  • Loading branch information
danielbankhead and ddelgrosso1 committed May 23, 2022
1 parent 99f3a2b commit c59dc96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"google storage",
"storage"
],
"mocha": {
"require": "ts-node/register",
"extension": "ts"
},
"scripts": {
"predocs": "npm run compile",
"docs": "jsdoc -c .jsdoc.js",
Expand Down
7 changes: 2 additions & 5 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metadata>;
Expand Down
18 changes: 9 additions & 9 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
}

Expand Down Expand Up @@ -1558,8 +1558,8 @@ class File extends ServiceObject<File> {
* `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.}
*/
/**
Expand Down Expand Up @@ -2030,7 +2030,7 @@ class File extends ServiceObject<File> {

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);
Expand Down

0 comments on commit c59dc96

Please sign in to comment.