Skip to content

Commit 912dc1a

Browse files
Allow list() at root (#5772)
1 parent a61786c commit 912dc1a

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

FirebaseStorage/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Unreleased
2+
- [fixed] Fixed a crash when listAll() was called at the root location. (#5772)
23

34
# 3.6.1
45
- [fixed] Fix a rare case where a StorageTask would call its completion callbacks more than

FirebaseStorage/Sources/FIRStorageListResult.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@ + (nullable FIRStorageListResult *)fromDictionary:(NSDictionary<NSString *, id>
3333
}
3434

3535
FIRStorageReference *prefixReference = [rootReference child:pathWithoutTrailingSlash];
36-
NSAssert([prefixReference.fullPath hasPrefix:reference.fullPath],
37-
@"Expected %@ to be a child element of %@", reference, prefixReference);
3836
[prefixes addObject:prefixReference];
3937
}
4038

4139
NSArray<NSDictionary<NSString *, NSString *> *> *itemEntries = dictionary[kFIRStorageListItems];
4240
for (NSDictionary<NSString *, NSString *> *itemEntry in itemEntries) {
4341
FIRStorageReference *itemReference = [rootReference child:itemEntry[kFIRStorageListItemName]];
44-
NSAssert([itemReference.fullPath hasPrefix:reference.fullPath],
45-
@"Expected %@ to be a child element of %@", reference, itemReference);
4642
[items addObject:itemReference];
4743
}
4844

FirebaseStorage/Tests/Integration/FIRStorageIntegrationTests.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
rules_version = '2';
3131
service firebase.storage {
3232
match /b/{bucket}/o {
33+
match /{directChild=*} {
34+
allow read: if request.auth != null;
35+
}
3336
match /ios {
3437
match /public/{allPaths=**} {
3538
allow write: if request.auth != null;
@@ -767,7 +770,7 @@ - (void)testPagedListFiles {
767770
}
768771

769772
- (void)testListAllFiles {
770-
XCTestExpectation *expectation = [self expectationWithDescription:@"testPagedListFiles"];
773+
XCTestExpectation *expectation = [self expectationWithDescription:@"testListAllFiles"];
771774

772775
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/list"];
773776

@@ -786,6 +789,22 @@ - (void)testListAllFiles {
786789
[self waitForExpectations];
787790
}
788791

792+
- (void)testListFilesAtRoot {
793+
XCTestExpectation *expectation = [self expectationWithDescription:@"testListFilesAtRoot"];
794+
795+
FIRStorageReference *ref = [self.storage referenceWithPath:@""];
796+
797+
[ref listAllWithCompletion:^(FIRStorageListResult *_Nullable listResult,
798+
NSError *_Nullable error) {
799+
XCTAssertNotNil(listResult);
800+
XCTAssertNil(error);
801+
XCTAssertNil(listResult.pageToken);
802+
[expectation fulfill];
803+
}];
804+
805+
[self waitForExpectations];
806+
}
807+
789808
- (void)waitForExpectations {
790809
[self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
791810
handler:^(NSError *_Nullable error) {

0 commit comments

Comments
 (0)