Skip to content

Commit

Permalink
fix: missing error when network fail
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Dec 7, 2023
1 parent 8eebcd2 commit ae71a69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
17 changes: 15 additions & 2 deletions ios/Plugin/CapacitorUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,22 @@ extension CustomError: LocalizedError {
})
self.saveBundleInfo(id: id, bundle: BundleInfo(id: id, version: version, status: BundleStatus.DOWNLOADING, downloaded: Date(), checksum: checksum))
self.notifyDownload(id, 0)
let reachabilityManager = NetworkReachabilityManager()
reachabilityManager?.startListening { status in
switch status {
case .notReachable:
// Stop the download request if the network is not reachable
request.cancel()
mainError = NSError(domain: NSURLErrorDomain, code: NSURLErrorNotConnectedToInternet, userInfo: nil)
semaphore.signal()
default:
break
}
}
semaphore.wait()
if mainError != nil {
throw mainError!
reachabilityManager?.stopListening()
if let error = mainError {
throw error
}
let info: BundleInfo = BundleInfo(id: id, version: version, status: BundleStatus.PENDING, downloaded: Date(), checksum: checksum)
self.saveBundleInfo(id: id, bundle: info)
Expand Down

0 comments on commit ae71a69

Please sign in to comment.