Skip to content

Commit 4cae565

Browse files
jonsimantova-maurice
authored andcommitted
Fix handling of Storage url() on desktop, and add an integration test to ensure
it gives the correct result when you create a Storage instance with an explicit or implicit url. PiperOrigin-RevId: 272991890
1 parent f2c6045 commit 4cae565

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

storage/src/common/storage.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ StorageReference Storage::GetReferenceFromUrl(const char* url) const {
184184

185185
static const char kObjectName[] = "StorageReference";
186186
// Extract components from this storage object's URL.
187-
std::string this_bucket;
188-
internal::UriToComponents(const_cast<Storage*>(this)->url(), kObjectName,
189-
&this_bucket, nullptr);
187+
std::string this_bucket = const_cast<Storage*>(this)->GetReference().bucket();
190188
// Make sure the specified URL is valid.
191189
std::string bucket;
192190
bool valid = internal::UriToComponents(std::string(url), kObjectName, &bucket,

storage/src/desktop/storage_desktop.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@ namespace internal {
3232

3333
StorageInternal::StorageInternal(App* app, const char* url) {
3434
app_ = app;
35+
3536
if (url) {
3637
url_ = url;
38+
root_ = StoragePath(url_);
3739
} else {
3840
const char* bucket = app->options().storage_bucket();
39-
if (bucket) url_ = std::string(kGsScheme) + bucket;
41+
root_ = StoragePath(bucket ? std::string(kGsScheme) + bucket : "");
4042
}
41-
root_ = StoragePath(url_);
4243

4344
// LINT.IfChange
4445
max_download_retry_time_ = 600.0;
4546
max_operation_retry_time_ = 120.0;
4647
max_upload_retry_time_ = 600.0;
47-
// LINT.ThenChange(//depot_android_gmscore_dev/\
48+
// LINT.ThenChange(//depot/google3/java/com/google/android/gmscore/integ/\
4849
// client/firebase-storage-api/src/com/google/firebase/\
4950
// storage/FirebaseStorage.java,
5051
// //depot_firebase_ios_Releases/FirebaseStorage/\
@@ -126,8 +127,8 @@ void StorageInternal::CleanupCompletedOperations() {
126127
for (auto it = operations_.begin(); it != operations_.end(); ++it) {
127128
if ((*it)->is_complete()) operations_to_delete.push_back(*it);
128129
}
129-
for (auto it = operations_to_delete.begin();
130-
it != operations_to_delete.end(); ++it) {
130+
for (auto it = operations_to_delete.begin(); it != operations_to_delete.end();
131+
++it) {
131132
RemoveOperation(*it);
132133
delete *it;
133134
}

storage/src/desktop/storage_desktop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class StorageInternal {
3939
// Get the firease::App that this Storage was created with.
4040
::firebase::App* app() { return app_; }
4141

42-
// Return the URL we were created with.
42+
// Return the URL we were created with, if we were created with it explicitly.
4343
std::string url() { return url_; }
4444

4545
// Get a StorageReference to the root of the database.

0 commit comments

Comments
 (0)