Skip to content

Commit 99e34b6

Browse files
committed
post review fixups
1 parent b978085 commit 99e34b6

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

lib/auth/v2/getCanonicalizedAmzHeaders.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export default function getCanonicalizedAmzHeaders(headers: ArsenalRequestHeader
1414
.filter(filterFn)
1515
.map(val => {
1616
const headerValue = headers[val];
17-
// AWS SDK v3 can pass header values as arrays (for multiple values),
18-
// strings, or other types. We need to normalize them before calling .trim()
19-
// Per HTTP spec and AWS Signature v2, multiple values are joined with commas
2017
const stringValue = normalizeHeaderValue(headerValue);
2118
return [val.trim(), stringValue.trim()];
2219
});

lib/storage/data/external/AwsClient.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const { prepareStream } = require('../../../s3middleware/prepareStream');
2828
const { createLogger, logHelper, removeQuotes, trimXMetaPrefix } =
2929
require('./utils');
3030
const jsutil = require('../../../jsutil');
31+
const { callbackify } = require('util');
3132

3233
const missingVerIdInternalError = errorInstances.InternalError.customizeDescription(
3334
'Invalid state. Please ensure versioning is enabled ' +
@@ -53,16 +54,16 @@ class AwsClient {
5354
if (typeof cb !== 'function') {
5455
throw new TypeError('AwsClient.setup requires a callback function');
5556
}
56-
const done = jsutil.once(cb);
57-
try {
57+
58+
const run = callbackify(async () => {
5859
const usEast1Client = new S3Client({
5960
...this._client.config,
6061
region: 'us-east-1',
6162
});
6263

6364
const applyRegion = region => {
6465
if (!region) {
65-
return done();
66+
return;
6667
}
6768

6869
const isAWS = this._s3Params.endpoint?.endsWith('amazonaws.com');
@@ -82,29 +83,27 @@ class AwsClient {
8283
}
8384

8485
this._client = new S3Client(newConfig);
85-
return done();
8686
};
8787

88-
return usEast1Client.send(
89-
new GetBucketLocationCommand({ Bucket: this._awsBucketName })
90-
).then(res => applyRegion(res.LocationConstraint))
91-
.catch(err => {
88+
try {
89+
const res = await usEast1Client.send(
90+
new GetBucketLocationCommand({ Bucket: this._awsBucketName })
91+
);
92+
applyRegion(res.LocationConstraint);
93+
} catch (err) {
9294
if (err.name === 'AuthorizationHeaderMalformed') {
93-
return applyRegion(err.region);
95+
applyRegion(err.region);
96+
return;
9497
}
9598
this._logger.error('error during setup', {
9699
error: err,
97100
method: 'AwsClient.setup',
98101
});
99-
return done(err);
100-
});
101-
} catch (err) {
102-
this._logger.error('unexpected error during setup', {
103-
error: err,
104-
method: 'AwsClient.setup',
105-
});
106-
return done(err);
107-
}
102+
throw err;
103+
}
104+
});
105+
106+
return run(cb);
108107
}
109108

110109
_createAwsKey(requestBucketName, requestObjectKey,
@@ -128,13 +127,12 @@ class AwsClient {
128127
const metaHeaders = trimXMetaPrefix(keyContext.metaHeaders);
129128
const log = createLogger(reqUids);
130129

131-
const putCb = async (err, data) => {
130+
const putCb = (err, data) => {
132131
if (err) {
133132
logHelper(log, 'error', 'err from data backend',
134133
err, this._dataStoreName, this.clientType);
135134
return callback(errorInstances.ServiceUnavailable
136-
.customizeDescription('Error returned from ' +
137-
`${this.type}: ${err.message}`),
135+
.customizeDescription(`Error returned from ${this.type}: ${err.message}`),
138136
);
139137
}
140138
let dataStoreVersionId = data.VersionId;
@@ -636,6 +634,7 @@ class AwsClient {
636634
`${this.type}: ${err.message}`));
637635
});
638636
}
637+
639638
uploadPartCopy(request, awsSourceKey, sourceLocationConstraintName, config, log, callback) {
640639
const destBucketName = request.bucketName;
641640
const destObjectKey = request.objectKey;

lib/storage/data/external/GCP/GcpService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ class GcpClient extends S3Client {
322322
* Initiate a multipart upload (emulated for GCP).
323323
* @param {object} params - S3 createMultipartUpload params
324324
* @param {function} callback
325-
*/
326325
createMultipartUpload(params, callback) {
327326
if (!params || !params.Bucket || !params.Key) {
328327
const error = errorInstances.InvalidRequest
@@ -347,6 +346,7 @@ class GcpClient extends S3Client {
347346
return callback(null, { UploadId: uploadId });
348347
});
349348
}
349+
*/
350350

351351
/**
352352
* Upload a part for MPU (emulated for GCP).

0 commit comments

Comments
 (0)