Skip to content

Commit 4d63873

Browse files
Ensure Storage initializer doesn't get called (#3294)
1 parent bc29da6 commit 4d63873

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Firebase/Storage/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Unreleased
2+
- [fixed] Ensure that users don't accidently invoke `Storage()` instead of `Storage.storage()`.
3+
If your code calls the constructor of Storage directly, we will throw an assertion failure,
4+
instead of crashing the process later as the instance is used (#3282).
5+
6+
# 3.3.0
27
- [added] Added `StorageReference.list()` and `StorageReference.listAll()`, which allows developers to list the files and folders under the given StorageReference.
38

49
# 3.2.1

Firebase/Storage/FIRStorage.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ - (instancetype)initWithApp:(FIRApp *)app
158158
return self;
159159
}
160160

161+
- (instancetype)init {
162+
NSAssert(false, @"Storage cannot be directly instantiated, use "
163+
"Storage.storage() or Storage.storage(app:) instead");
164+
return nil;
165+
}
166+
161167
#pragma mark - NSObject overrides
162168

163169
- (instancetype)copyWithZone:(NSZone *)zone {

Firebase/Storage/Public/FIRStorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ NS_SWIFT_NAME(Storage)
6969
*/
7070
+ (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url NS_SWIFT_NAME(storage(app:url:));
7171

72+
- (instancetype)init NS_UNAVAILABLE;
73+
7274
/**
7375
* The Firebase App associated with this Firebase Storage instance.
7476
*/

0 commit comments

Comments
 (0)