Skip to content

Commit

Permalink
Merge 6913a61 into fa28299
Browse files Browse the repository at this point in the history
  • Loading branch information
TPXP authored Dec 18, 2020
2 parents fa28299 + 6913a61 commit 2dc6f70
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/storage/e2e/StorageReference.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ describe('storage() -> StorageReference', function() {
result.prefixes.length.should.be.greaterThan(0);
result.prefixes[0].constructor.name.should.eql('StorageReference');
});

it('should not crash if the user is not allowed to list the directory', async function() {
const storageReference = firebase.storage().ref('/forbidden');
try {
await storageReference.listAll();
return Promise.reject(new Error('listAll on a forbidden directory succeeded'));
} catch (error) {
error.code.should.equal('storage/unauthorized');
error.message.should.equal(
'[storage/unauthorized] User is not authorized to perform the desired action.',
);
return Promise.resolve();
}
});
});

describe('updateMetadata', function() {
Expand Down
9 changes: 9 additions & 0 deletions packages/storage/ios/RNFBStorage/RNFBStorageModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@ - (void)invalidate {
) {
FIRStorageReference *storageReference = [self getReferenceFromUrl:url app:firebaseApp];

__block bool alreadyCompleted = false;

id completionBlock = ^(FIRStorageListResult *result, NSError *error) {
// This may be called multiple times if an error occurs
// Make sure we won't try to resolve the promise twice in this case
// TODO - remove pending resolution of https://github.com/firebase/firebase-ios-sdk/issues/7197
if (alreadyCompleted) {
return;
}
alreadyCompleted = true;
if (error != nil) {
[self promiseRejectStorageException:reject error:error];
} else {
Expand Down

0 comments on commit 2dc6f70

Please sign in to comment.