Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions CountItems/CountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class CountManager {
this.log = params.log;
this.workers = params.workers;
this.maxConcurrent = params.maxConcurrent;
this.temporaryStore = {};
this.temporaryStore = {
account: {},
bucket: {},
};
this.store = {
objects: 0,
versions: 0,
Expand Down Expand Up @@ -94,14 +97,14 @@ class CountManager {
this.dataMetrics[metricLevel][resourceName],
results.dataMetrics[metricLevel][resourceName],
);
// if metricLevel is account, add the locations details
if (metricLevel === 'account') {
// if metricLevel is account or bucket, add the locations details
if (metricLevel === 'account' || metricLevel === 'bucket') {
Object.keys((results.dataMetrics[metricLevel][resourceName].locations || {})).forEach(locationName => {
if (!this.temporaryStore[resourceName]) {
this.temporaryStore[resourceName] = {};
if (!this.temporaryStore[metricLevel][resourceName]) {
this.temporaryStore[metricLevel][resourceName] = {};
}
this.temporaryStore[resourceName][locationName] = consolidateDataMetrics(
this.temporaryStore[resourceName][locationName],
this.temporaryStore[metricLevel][resourceName][locationName] = consolidateDataMetrics(
this.temporaryStore[metricLevel][resourceName][locationName],
results.dataMetrics[metricLevel][resourceName].locations[locationName],
);
});
Expand All @@ -110,8 +113,12 @@ class CountManager {
}
});
// Add the accounts details for locations from the temporary store
Object.keys(this.temporaryStore).forEach(accountName => {
this.dataMetrics.account[accountName].locations = this.temporaryStore[accountName];
Object.keys(this.temporaryStore.account).forEach(accountName => {
this.dataMetrics.account[accountName].locations = this.temporaryStore.account[accountName];
});
// Add the locations details for buckets from the temporary store
Object.keys(this.temporaryStore.bucket).forEach(bucketName => {
this.dataMetrics.bucket[bucketName].locations = this.temporaryStore.bucket[bucketName];
});
} else {
this.dataMetrics = results.dataMetrics;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3utils",
"version": "1.15.7",
"version": "1.15.8",
"engines": {
"node": ">= 16"
},
Expand Down
14 changes: 14 additions & 0 deletions tests/functional/countItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ const expectedDataMetrics = {
[`bucket_test-bucket-0_${testBucketCreationDate}`]: {
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
usedCapacity: { current: 1000n, nonCurrent: 0n },
locations: {
'secondary-location-1': {
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'secondary-location-2': {
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'us-east-1': {
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n },
usedCapacity: { current: 9000n, nonCurrent: 6000n },
},
},
},
[`bucket_test-bucket-1_${testBucketCreationDate}`]: {
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
Expand Down
Loading