Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Storage initializer doesn't get called #3294

Merged
merged 2 commits into from
Jul 2, 2019
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
5 changes: 5 additions & 0 deletions Firebase/Storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Unreleased
- [fixed] Ensure that users don't accidently invoke `Storage()` instead of `Storage.storage()`.
If your code calls the constructor of Storage directly, we will throw an assertion failure,
instead of crashing the process later as the instance is used (#3282).

# 3.3.0
- [added] Added `StorageReference.list()` and `StorageReference.listAll()`, which allows developers to list the files and folders under the given StorageReference.

# 3.2.1
Expand Down
6 changes: 6 additions & 0 deletions Firebase/Storage/FIRStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ - (instancetype)initWithApp:(FIRApp *)app
return self;
}

- (instancetype)init {
NSAssert(false, @"Storage cannot be directly instantiated, use "
"Storage.storage() or Storage.storage(app:) instead");
return nil;
}

#pragma mark - NSObject overrides

- (instancetype)copyWithZone:(NSZone *)zone {
Expand Down
2 changes: 2 additions & 0 deletions Firebase/Storage/Public/FIRStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ NS_SWIFT_NAME(Storage)
*/
+ (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url NS_SWIFT_NAME(storage(app:url:));

- (instancetype)init NS_UNAVAILABLE;

/**
* The Firebase App associated with this Firebase Storage instance.
*/
Expand Down