Skip to content

Commit 0be4da7

Browse files
committed
fixup post reviews
1 parent 13d272c commit 0be4da7

File tree

5 files changed

+932
-250
lines changed

5 files changed

+932
-250
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
},
2020
"homepage": "https://github.com/scality/S3#readme",
2121
"dependencies": {
22-
"@aws-sdk/client-s3": "^3.705.0",
22+
"@aws-sdk/client-s3": "^3.908.0",
2323
"@aws-sdk/credential-providers": "^3.864.0",
2424
"@azure/storage-blob": "^12.28.0",
2525
"@hapi/joi": "^17.1.1",
2626
"arsenal": "git+https://github.com/scality/Arsenal#8.2.41",
2727
"async": "2.6.4",
28-
"aws-sdk": "^2.1692.0",
2928
"bucketclient": "scality/bucketclient#8.2.7",
3029
"bufferutil": "^4.0.8",
3130
"commander": "^12.1.0",

tests/functional/aws-node-sdk/lib/utility/bucket-util.js

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ class BucketUtility {
5353
return this.s3.send(new CreateBucketCommand({
5454
Bucket: bucketName,
5555
ObjectLockEnabledForBucket: true,
56-
}))
57-
.then(() => bucketName)
58-
.catch(err => {
59-
throw err;
60-
});
56+
})).then(() => bucketName)
6157
}
6258

6359
createMany(bucketNames) {
@@ -79,10 +75,7 @@ class BucketUtility {
7975
}
8076

8177
deleteOne(bucketName) {
82-
return this.s3.send(new DeleteBucketCommand({ Bucket: bucketName }))
83-
.catch(err => {
84-
throw err;
85-
});
78+
return this.s3.send(new DeleteBucketCommand({ Bucket: bucketName }));
8679
}
8780

8881
deleteMany(bucketNames) {
@@ -97,48 +90,46 @@ class BucketUtility {
9790
* @param bucketName
9891
* @returns {Promise.<T>}
9992
*/
100-
101-
async empty(bucketName, BypassGovernanceRetention = false) {
93+
empty(bucketName, BypassGovernanceRetention = false) {
10294
const param = {
10395
Bucket: bucketName,
10496
};
10597

10698
return this.s3.send(new ListObjectVersionsCommand(param))
10799
.then(data => Promise.all(
108100
(data.Versions || [])
109-
.filter(object => !object.Key.endsWith('/'))
101+
.filter(object => !object.Key.endsWith('/'))
102+
.map(object =>
103+
this.s3.send(new DeleteObjectCommand({
104+
Bucket: bucketName,
105+
Key: object.Key,
106+
VersionId: object.VersionId,
107+
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
108+
})).then(() => object)
109+
)
110+
.concat((data.Versions || [])
111+
.filter(object => object.Key.endsWith('/'))
110112
.map(object =>
111113
this.s3.send(new DeleteObjectCommand({
112114
Bucket: bucketName,
113115
Key: object.Key,
114116
VersionId: object.VersionId,
115117
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
116118
}))
117-
.then(() => object)
118-
)
119-
.concat((data.Versions || [])
120-
.filter(object => object.Key.endsWith('/'))
121-
.map(object =>
122-
this.s3.send(new DeleteObjectCommand({
123-
Bucket: bucketName,
124-
Key: object.Key,
125-
VersionId: object.VersionId,
126-
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
127-
}))
128-
.then(() => object)
129-
)
119+
.then(() => object)
130120
)
131-
.concat((data.DeleteMarkers || [])
132-
.map(object =>
133-
this.s3.send(new DeleteObjectCommand({
134-
Bucket: bucketName,
135-
Key: object.Key,
136-
VersionId: object.VersionId,
137-
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
138-
}))
139-
.then(() => object)
140-
)
121+
)
122+
.concat((data.DeleteMarkers || [])
123+
.map(object =>
124+
this.s3.send(new DeleteObjectCommand({
125+
Bucket: bucketName,
126+
Key: object.Key,
127+
VersionId: object.VersionId,
128+
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
129+
}))
130+
.then(() => object)
141131
)
132+
)
142133
)
143134
);
144135
}
@@ -147,7 +138,6 @@ class BucketUtility {
147138
const promises = bucketNames.map(
148139
bucketName => this.empty(bucketName)
149140
);
150-
151141
return Promise.all(promises);
152142
}
153143

@@ -159,6 +149,7 @@ class BucketUtility {
159149
return undefined;
160150
});
161151
}
152+
162153
emptyManyIfExists(bucketNames) {
163154
const promises = bucketNames.map(bucketName =>
164155
this.emptyIfExists(bucketName),

tests/sur/quota.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ function putObjectWithCustomHeader(bucket, key, size, vID, cb) {
104104
Body: Buffer.alloc(size),
105105
};
106106

107-
// Add custom header using middleware
108107
const command = new PutObjectCommand(params);
109108
command.middlewareStack.add(
110109
next => async args => {
@@ -323,14 +322,13 @@ function restoreObject(bucket, key, size, callback) {
323322
RestoreRequest: {
324323
Days: 1,
325324
},
326-
}))
327-
.then(data => {
328-
if (!s3Config.isQuotaInflightEnabled()) {
329-
mockScuba.incrementBytesForBucket(bucket, size);
330-
}
331-
return callback(null, data);
332-
})
333-
.catch(callback);
325+
})).then(data => {
326+
if (!s3Config.isQuotaInflightEnabled()) {
327+
mockScuba.incrementBytesForBucket(bucket, size);
328+
}
329+
return callback(null, data);
330+
})
331+
.catch(callback);
334332
}
335333

336334
function multiObjectDelete(bucket, keys, size, callback) {

tests/utapi/awsNodeSdk.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function createBucket(bucket, cb) {
3333

3434
function deleteBucket(bucket, cb) {
3535
s3Client.send(new DeleteBucketCommand({ Bucket: bucket }))
36-
.then(() => cb())
36+
.then(() => cb(null))
3737
.catch(cb);
3838
}
3939

@@ -51,7 +51,7 @@ function putObject(bucket, key, size, cb) {
5151

5252
function deleteObject(bucket, key, cb) {
5353
s3Client.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }))
54-
.then(() => cb())
54+
.then(() => cb(null))
5555
.catch(cb);
5656
}
5757

@@ -63,22 +63,22 @@ function deleteObjects(bucket, keys, cb) {
6363
Delete: deleteRequest,
6464
};
6565
s3Client.send(new DeleteObjectsCommand(params))
66-
.then(() => cb())
66+
.then(() => cb(null))
6767
.catch(cb);
6868
}
6969

7070
function copyObject(bucket, key, cb) {
7171
const params = { Bucket: bucket, CopySource: `${bucket}/${key}`, Key: `${key}-copy` };
7272
s3Client.send(new CopyObjectCommand(params))
73-
.then(() => cb())
73+
.then(() => cb(null))
7474
.catch(cb);
7575
}
7676

7777
function enableVersioning(bucket, enable, cb) {
7878
const versioningStatus = { Status: enable ? 'Enabled' : 'Disabled' };
7979
const params = { Bucket: bucket, VersioningConfiguration: versioningStatus };
8080
s3Client.send(new PutBucketVersioningCommand(params))
81-
.then(() => cb())
81+
.then(() => cb(null))
8282
.catch(cb);
8383
}
8484

0 commit comments

Comments
 (0)