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
1 change: 1 addition & 0 deletions FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Unreleased
- [fixed] Fixed a crash when listAll() was called at the root location. (#5772)

# 3.6.1
- [fixed] Fix a rare case where a StorageTask would call its completion callbacks more than
Expand Down
4 changes: 0 additions & 4 deletions FirebaseStorage/Sources/FIRStorageListResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ + (nullable FIRStorageListResult *)fromDictionary:(NSDictionary<NSString *, id>
}

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

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

Expand Down
21 changes: 20 additions & 1 deletion FirebaseStorage/Tests/Integration/FIRStorageIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{directChild=*} {
allow read: if request.auth != null;
}
match /ios {
match /public/{allPaths=**} {
allow write: if request.auth != null;
Expand Down Expand Up @@ -768,7 +771,7 @@ - (void)testPagedListFiles {
}

- (void)testListAllFiles {
XCTestExpectation *expectation = [self expectationWithDescription:@"testPagedListFiles"];
XCTestExpectation *expectation = [self expectationWithDescription:@"testListAllFiles"];

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

Expand All @@ -787,6 +790,22 @@ - (void)testListAllFiles {
[self waitForExpectations];
}

- (void)testListFilesAtRoot {
XCTestExpectation *expectation = [self expectationWithDescription:@"testListFilesAtRoot"];

FIRStorageReference *ref = [self.storage referenceWithPath:@""];

[ref listAllWithCompletion:^(FIRStorageListResult *_Nullable listResult,
NSError *_Nullable error) {
XCTAssertNotNil(listResult);
XCTAssertNil(error);
XCTAssertNil(listResult.pageToken);
[expectation fulfill];
}];

[self waitForExpectations];
}

- (void)waitForExpectations {
[self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
handler:^(NSError *_Nullable error) {
Expand Down