Skip to content

Commit 788ea64

Browse files
committed
TODO cleanup
1 parent 0116249 commit 788ea64

File tree

3 files changed

+20
-41
lines changed

3 files changed

+20
-41
lines changed

FirebaseStorage/Sources/Storage.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ import FirebaseAuthInterop
208208

209209
internal let impl: FIRIMPLStorage
210210

211-
internal var fetcherServiceForApp: GTMSessionFetcherService? {
211+
internal var fetcherServiceForApp: GTMSessionFetcherService {
212212
get {
213-
return impl.fetcherServiceForApp
213+
guard let fetcherService = impl.fetcherServiceForApp else {
214+
fatalError("Internal Error: fetcherService not configured")
215+
}
216+
return fetcherService
214217
}
215218
set(newValue) {
216219
impl.fetcherServiceForApp = newValue

FirebaseStorage/Sources/StorageReference.swift

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ import FirebaseStorageInternal
135135
putMetadata.path = path
136136
putMetadata.name = (path as NSString).lastPathComponent as String
137137
}
138-
guard let fetcherService = storage.fetcherServiceForApp else {
139-
fatalError("TODO: Internal Error: fetcherService not configured")
140-
}
138+
let fetcherService = storage.fetcherServiceForApp
141139
let task = StorageUploadTask(reference: impl,
142140
service: fetcherService,
143141
queue: storage.dispatchQueue,
@@ -216,9 +214,7 @@ import FirebaseStorageInternal
216214
} else {
217215
putMetadata = metadata!
218216
}
219-
guard let fetcherService = storage.fetcherServiceForApp else {
220-
fatalError("TODO: Internal Error: fetcherService not configured")
221-
}
217+
let fetcherService = storage.fetcherServiceForApp
222218
let task = StorageUploadTask(reference: impl,
223219
service: fetcherService,
224220
queue: storage.dispatchQueue,
@@ -266,9 +262,7 @@ import FirebaseStorageInternal
266262
@objc(dataWithMaxSize:completion:) @discardableResult
267263
open func getData(maxSize: Int64,
268264
completion: @escaping ((_: Data?, _: Error?) -> Void)) -> StorageDownloadTask {
269-
guard let fetcherService = storage.fetcherServiceForApp else {
270-
fatalError("TODO: Internal Error: fetcherService not configured")
271-
}
265+
let fetcherService = storage.fetcherServiceForApp
272266
let task = StorageDownloadTask(reference: impl,
273267
service: fetcherService,
274268
queue: storage.dispatchQueue,
@@ -317,9 +311,7 @@ import FirebaseStorageInternal
317311
*/
318312
@objc(downloadURLWithCompletion:)
319313
open func downloadURL(completion: @escaping ((_: URL?, _: Error?) -> Void)) {
320-
guard let fetcherService = storage.fetcherServiceForApp else {
321-
fatalError("TODO: Internal Error: fetcherService not configured")
322-
}
314+
let fetcherService = storage.fetcherServiceForApp
323315
let task = StorageGetDownloadURLTask(reference: impl,
324316
fetcherService: fetcherService,
325317
queue: storage.dispatchQueue,
@@ -367,9 +359,7 @@ import FirebaseStorageInternal
367359
@objc(writeToFile:completion:) @discardableResult
368360
open func write(toFile fileURL: URL,
369361
completion: ((_: URL?, _: Error?) -> Void)?) -> StorageDownloadTask {
370-
guard let fetcherService = storage.fetcherServiceForApp else {
371-
fatalError("TODO: Internal Error: fetcherService not configured")
372-
}
362+
let fetcherService = storage.fetcherServiceForApp
373363
let task = StorageDownloadTask(reference: impl,
374364
service: fetcherService,
375365
queue: storage.dispatchQueue,
@@ -416,9 +406,7 @@ import FirebaseStorageInternal
416406
*/
417407
@objc(listAllWithCompletion:)
418408
open func listAll(completion: @escaping ((_: StorageListResult?, _: NSError?) -> Void)) {
419-
guard let fetcherService = storage.fetcherServiceForApp else {
420-
fatalError("TODO: Internal Error: fetcherService not configured")
421-
}
409+
let fetcherService = storage.fetcherServiceForApp
422410
var prefixes = [FIRIMPLStorageReference]()
423411
var items = [FIRIMPLStorageReference]()
424412

@@ -461,7 +449,6 @@ import FirebaseStorageInternal
461449
queue: storage.dispatchQueue,
462450
pageSize: nil,
463451
previousPageToken: nil,
464-
// TODO: fix next line
465452
completion: paginatedCompletion)
466453
task.enqueue()
467454
}
@@ -514,9 +501,7 @@ import FirebaseStorageInternal
514501
userInfo: [NSLocalizedDescriptionKey:
515502
"Argument 'maxResults' must be between 1 and 1000 inclusive."]))
516503
} else {
517-
guard let fetcherService = storage.fetcherServiceForApp else {
518-
fatalError("TODO: Internal Error: fetcherService not configured")
519-
}
504+
let fetcherService = storage.fetcherServiceForApp
520505
let task = StorageListTask(reference: impl,
521506
fetcherService: fetcherService,
522507
queue: storage.dispatchQueue,
@@ -556,9 +541,7 @@ import FirebaseStorageInternal
556541
userInfo: [NSLocalizedDescriptionKey:
557542
"Argument 'maxResults' must be between 1 and 1000 inclusive."]))
558543
} else {
559-
guard let fetcherService = storage.fetcherServiceForApp else {
560-
fatalError("TODO: Internal Error: fetcherService not configured")
561-
}
544+
let fetcherService = storage.fetcherServiceForApp
562545
let task = StorageListTask(reference: impl,
563546
fetcherService: fetcherService,
564547
queue: storage.dispatchQueue,
@@ -578,9 +561,7 @@ import FirebaseStorageInternal
578561
*/
579562
@objc(metadataWithCompletion:)
580563
open func getMetadata(completion: @escaping ((_: StorageMetadata?, _: Error?) -> Void)) {
581-
guard let fetcherService = storage.fetcherServiceForApp else {
582-
fatalError("TODO: Internal Error: fetcherService not configured")
583-
}
564+
let fetcherService = storage.fetcherServiceForApp
584565
let task = StorageGetMetadataTask(reference: impl,
585566
fetcherService: fetcherService,
586567
queue: storage.dispatchQueue,
@@ -614,9 +595,7 @@ import FirebaseStorageInternal
614595
@objc(updateMetadata:completion:)
615596
open func updateMetadata(_ metadata: StorageMetadata,
616597
completion: ((_: StorageMetadata?, _: Error?) -> Void)?) {
617-
guard let fetcherService = storage.fetcherServiceForApp else {
618-
fatalError("TODO: Internal Error: fetcherService not configured")
619-
}
598+
let fetcherService = storage.fetcherServiceForApp
620599
let task = StorageUpdateMetadataTask(reference: impl,
621600
fetcherService: fetcherService,
622601
queue: storage.dispatchQueue,
@@ -662,9 +641,7 @@ import FirebaseStorageInternal
662641
*/
663642
@objc(deleteWithCompletion:)
664643
open func delete(completion: ((_: Error?) -> Void)?) {
665-
guard let fetcherService = storage.fetcherServiceForApp else {
666-
fatalError("TODO: Internal Error: fetcherService not configured")
667-
}
644+
let fetcherService = storage.fetcherServiceForApp
668645
let task = StorageDeleteTask(reference: impl,
669646
fetcherService: fetcherService,
670647
queue: storage.dispatchQueue,

FirebaseStorage/Sources/StorageUploadTask.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ import FirebaseStorageInternal
6767
let path = components?.path {
6868
components?.percentEncodedPath = "/upload\(path)"
6969
}
70-
// TODO: - internal error
7170
guard let path = strongSelf.GCSEscapedString(self.uploadMetadata.path) else {
72-
fatalError("TODO")
71+
fatalError("Internal error enqueueing a Storage task")
7372
}
7473
components?.percentEncodedQuery = "uploadType=resumable&name=\(path)"
7574

7675
request.url = components?.url
7776

7877
guard let contentType = strongSelf.uploadMetadata.contentType else {
79-
fatalError("ToDo")
78+
fatalError("Internal error enqueueing a Storage task")
8079
}
8180
let uploadFetcher = GTMSessionUploadFetcher(
8281
request: request,
@@ -175,8 +174,8 @@ import FirebaseStorageInternal
175174
if weakSelf?.state != .success {
176175
weakSelf?.metadata = weakSelf?.uploadMetadata
177176
}
178-
// TODO:
179-
// weakSelf.error = [FIRStorageErrors errorWithCode:FIRIMPLStorageErrorCodeCancelled];
177+
weakSelf?.error = StorageErrorCode.error(withServerError: StorageErrorCode.cancelled as NSError,
178+
ref: self.reference)
180179
if let snapshot = weakSelf?.snapshot {
181180
weakSelf?.fire(for: .failure, snapshot: snapshot)
182181
}

0 commit comments

Comments
 (0)