Skip to content

Commit aa003c7

Browse files
committed
address comments
1 parent 6ce9f46 commit aa003c7

File tree

3 files changed

+31
-37
lines changed

3 files changed

+31
-37
lines changed

packages/firebase/index.d.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,15 +5437,16 @@ declare namespace firebase.storage {
54375437
/**
54385438
* List all items (files) and prefixes (folders) under this storage reference.
54395439
*
5440-
* It is a helper method for calling list() recursively until there is no
5441-
* more results. The default pagination size is 200.
5440+
* This is a helper method for calling list() repeatedly until there are no
5441+
* more results. The default pagination size is 1000.
54425442
*
5443-
* Note: the results may not be a consistent snapshot if objects are changed
5443+
* Note: The results may not be a consistent snapshot if objects are changed
54445444
* between paginating requests.
54455445
*
5446-
* Warning: If there are
5446+
* Warning: listAll may potentially consume too many resources if there are
5447+
* too many results.
54475448
*
5448-
* @return A promise that resolves with all the items and prefixes under
5449+
* @return A Promise that resolves with all the items and prefixes under
54495450
* the current storage reference. `prefixes` contains references to
54505451
* sub-directories and `items` contains references to objects in this
54515452
* folder. `nextPageToken` is never returned.
@@ -5454,18 +5455,14 @@ declare namespace firebase.storage {
54545455
/**
54555456
* List items (files) and prefixes (folders) under this storage reference.
54565457
*
5457-
* GCS is a key-blob store. Firebase storage impose the semantic of '/'
5458+
* GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
54585459
* delimited folder structure.
5459-
* Objects whose paths, aside from the prefix, contain '/' will have
5460-
* their path, truncated after the '/', returned in prefixes.
5461-
* Duplicate prefixes are omitted.
5462-
* Objects whose paths, aside from the prefix, do not contain '/' will
5463-
* be returned in items.
5464-
*
5465-
* Firebase storage does not support invalid object paths that end with
5466-
* "/" or contain two consecutive "/"s. All invalid objects in GCS will be
5467-
* filtered by GCS.
5468-
* list() may fail if there are too many invalid objects in the bucket.
5460+
* Refer to GCS's List API if you want to learn more.
5461+
*
5462+
* To adhere to Firebase Rules's Semantics, Firebase storage does not
5463+
* support objects whose paths end with "/" or contain two consecutive
5464+
* "/"s. Firebase Storage List API will filter these unsupported objects.
5465+
* list() may fail if there are too many unsupported objects in the bucket.
54695466
*
54705467
* @param options.maxResults If set, limits the total number of `prefixes`
54715468
* and `items` to return. The default and maximum maxResults is 1000.

packages/storage/src/reference.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,16 @@ export class Reference {
206206
/**
207207
* List all items (files) and prefixes (folders) under this storage reference.
208208
*
209-
* It is a helper method for calling list() recursively until there is no
210-
* more results. The default pagination size is 200.
209+
* This is a helper method for calling list() repeatedly until there are no
210+
* more results. The default pagination size is 1000.
211211
*
212-
* Note: the results may not be a consistent snapshot if objects are changed
212+
* Note: The results may not be a consistent snapshot if objects are changed
213213
* between paginating requests.
214214
*
215-
* Warning: If there are
215+
* Warning: listAll may potentially consume too many resources if there are
216+
* too many results.
216217
*
217-
* @return A promise that resolves with all the items and prefixes under
218+
* @return A Promise that resolves with all the items and prefixes under
218219
* the current storage reference. `prefixes` contains references to
219220
* sub-directories and `items` contains references to objects in this
220221
* folder. `nextPageToken` is never returned.
@@ -233,32 +234,28 @@ export class Reference {
233234
pageToken?: string
234235
): Promise<void> {
235236
let opt: ListOptions = {
236-
maxResults: 1,
237+
// maxResults is 1000 by default.
237238
pageToken
238239
};
239240
const nextPage = await this.list(opt);
240-
Array.prototype.push.apply(accumulator.prefixes, nextPage.prefixes);
241-
Array.prototype.push.apply(accumulator.items, nextPage.items);
242-
if (nextPage.nextPageToken) {
241+
accumulator.prefixes(...nextPage.prefixes);
242+
accumulator.items(...nextPage.items);
243+
if (nextPage.nextPageToken === undefined) {
243244
await this.listAllHelper(accumulator, nextPage.nextPageToken);
244245
}
245246
}
246247

247248
/**
248249
* List items (files) and prefixes (folders) under this storage reference.
249250
*
250-
* GCS is a key-blob store. Firebase storage impose the semantic of '/'
251+
* GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
251252
* delimited folder structure.
252-
* Objects whose paths, aside from the prefix, contain '/' will have
253-
* their path, truncated after the '/', returned in prefixes.
254-
* Duplicate prefixes are omitted.
255-
* Objects whose paths, aside from the prefix, do not contain '/' will
256-
* be returned in items.
253+
* Refer to GCS's List API if you want to learn more.
257254
*
258-
* Firebase storage does not support invalid object paths that end with
259-
* "/" or contain two consecutive "/"s. All invalid objects in GCS will be
260-
* filtered by GCS.
261-
* list() may fail if there are too many invalid objects in the bucket.
255+
* To adhere to Firebase Rules's Semantics, Firebase storage does not
256+
* support objects whose paths end with "/" or contain two consecutive
257+
* "/"s. Firebase Storage List API will filter these unsupported objects.
258+
* list() may fail if there are too many unsupported objects in the bucket.
262259
*
263260
* @param options.maxResults If set, limits the total number of `prefixes`
264261
* and `items` to return. The default and maximum maxResults is 1000.

packages/storage/test/reference.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,12 @@ describe('Firebase Storage > Reference', () => {
576576
'storage/invalid-root-operation'
577577
);
578578
});
579-
it("listAll doesn't throws", () => {
579+
it("listAll doesn't throw", () => {
580580
assert.doesNotThrow(() => {
581581
root.listAll();
582582
});
583583
});
584-
it("list doesn't throws", () => {
584+
it("list doesn't throw", () => {
585585
assert.doesNotThrow(() => {
586586
root.list();
587587
});

0 commit comments

Comments
 (0)