Skip to content

Commit 4f9b629

Browse files
committed
fixup post reviews
1 parent adb7ac5 commit 4f9b629

File tree

5 files changed

+932
-249
lines changed

5 files changed

+932
-249
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.32",
2727
"async": "2.6.4",
28-
"aws-sdk": "^2.1692.0",
2928
"bucketclient": "scality/bucketclient#8.2.5",
3029
"bufferutil": "^4.0.8",
3130
"commander": "^12.1.0",

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

Lines changed: 27 additions & 35 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) {
@@ -66,6 +62,7 @@ class BucketUtility {
6662
);
6763
return Promise.all(promises);
6864
}
65+
6966
createRandom(nBuckets = 1) {
7067
if (nBuckets === 1) {
7168
const bucketName = projectFixture.generateBucketName();
@@ -78,10 +75,7 @@ class BucketUtility {
7875
}
7976

8077
deleteOne(bucketName) {
81-
return this.s3.send(new DeleteBucketCommand({ Bucket: bucketName }))
82-
.catch(err => {
83-
throw err;
84-
});
78+
return this.s3.send(new DeleteBucketCommand({ Bucket: bucketName }));
8579
}
8680

8781
deleteMany(bucketNames) {
@@ -90,12 +84,12 @@ class BucketUtility {
9084
);
9185
return Promise.all(promises);
9286
}
87+
9388
/**
9489
* Recursively delete all versions of all objects within the bucket
9590
* @param bucketName
9691
* @returns {Promise.<T>}
9792
*/
98-
9993
empty(bucketName, BypassGovernanceRetention = false) {
10094
const param = {
10195
Bucket: bucketName,
@@ -104,39 +98,38 @@ class BucketUtility {
10498
return this.s3.send(new ListObjectVersionsCommand(param))
10599
.then(data => Promise.all(
106100
(data.Versions || [])
107-
.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('/'))
108112
.map(object =>
109113
this.s3.send(new DeleteObjectCommand({
110114
Bucket: bucketName,
111115
Key: object.Key,
112116
VersionId: object.VersionId,
113117
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
114118
}))
115-
.then(() => object)
119+
.then(() => object)
116120
)
117-
.concat((data.Versions || [])
118-
.filter(object => object.Key.endsWith('/'))
119-
.map(object =>
120-
this.s3.send(new DeleteObjectCommand({
121-
Bucket: bucketName,
122-
Key: object.Key,
123-
VersionId: object.VersionId,
124-
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
125-
}))
126-
.then(() => object)
127-
)
128-
)
129-
.concat((data.DeleteMarkers || [])
130-
.map(object =>
131-
this.s3.send(new DeleteObjectCommand({
132-
Bucket: bucketName,
133-
Key: object.Key,
134-
VersionId: object.VersionId,
135-
...(BypassGovernanceRetention && { BypassGovernanceRetention }),
136-
}))
137-
.then(() => object)
138-
)
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)
139131
)
132+
)
140133
)
141134
);
142135
}
@@ -145,7 +138,6 @@ class BucketUtility {
145138
const promises = bucketNames.map(
146139
bucketName => this.empty(bucketName)
147140
);
148-
149141
return Promise.all(promises);
150142
}
151143

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)