Skip to content

Commit 4d22b2a

Browse files
committed
refactor: Simplify partial success placeholder logic
1 parent 934af50 commit 4d22b2a

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

src/storage.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,13 +1345,7 @@ export class Storage extends Service {
13451345
const buckets = itemsArray.map((bucket: BucketMetadata) => {
13461346
const bucketInstance = this.bucket(bucket.id!);
13471347
bucketInstance.metadata = bucket;
1348-
1349-
if (returnPartialSuccess) {
1350-
const unreachableBucketId = `projects/_/buckets/${bucket.id}`;
1351-
if (unreachableArray.includes(unreachableBucketId)) {
1352-
bucketInstance.unreachable = true;
1353-
}
1354-
}
1348+
bucketInstance.unreachable = false;
13551349
return bucketInstance;
13561350
});
13571351

@@ -1361,16 +1355,10 @@ export class Storage extends Service {
13611355
.map((fullPath: string) => {
13621356
const name = fullPath.split('/').pop();
13631357
if (!name) return null;
1364-
const exists = new Set(buckets.map((b: Bucket) => b.name)).has(
1365-
name
1366-
);
1367-
if (!exists) {
1368-
const placeholder = this.bucket(name);
1369-
placeholder.unreachable = true;
1370-
placeholder.metadata = {};
1371-
return placeholder;
1372-
}
1373-
return null;
1358+
const placeholder = this.bucket(name);
1359+
placeholder.unreachable = true;
1360+
placeholder.metadata = {};
1361+
return placeholder;
13741362
})
13751363
.filter(Boolean) as Bucket[];
13761364
}

test/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ describe('Storage', () => {
12011201
b => b.name === 'fake-bucket-name'
12021202
);
12031203
assert.ok(reachableBucket);
1204-
assert.strictEqual(reachableBucket!.unreachable, undefined);
1204+
assert.strictEqual(reachableBucket!.unreachable, false);
12051205

12061206
const unreachableBucket = buckets.find(b => b.name === 'fail-bucket');
12071207
assert.ok(unreachableBucket);

0 commit comments

Comments
 (0)