mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-17 18:53:40 +01:00
Adds basic error handling when downloading OTA firmware
This commit is contained in:
@@ -161,13 +161,20 @@ private extension PatchAppOperation
|
|||||||
try FileManager.default.createDirectory(at: self.patchDirectory, withIntermediateDirectories: true, attributes: nil)
|
try FileManager.default.createDirectory(at: self.patchDirectory, withIntermediateDirectories: true, attributes: nil)
|
||||||
|
|
||||||
let archiveURL = self.patchDirectory.appendingPathComponent("ota.archive")
|
let archiveURL = self.patchDirectory.appendingPathComponent("ota.archive")
|
||||||
archiveURL.withUnsafeFileSystemRepresentation { archivePath in
|
try archiveURL.withUnsafeFileSystemRepresentation { archivePath in
|
||||||
let fz = fragmentzip_open((update.url.absoluteString as NSString).utf8String!)
|
guard let fz = fragmentzip_open((update.url.absoluteString as NSString).utf8String!) else {
|
||||||
|
throw URLError(.cannotConnectToHost, userInfo: [NSLocalizedDescriptionKey: NSLocalizedString("The connection failed because a connection cannot be made to the host.", comment: ""),
|
||||||
|
NSURLErrorKey: update.url])
|
||||||
|
}
|
||||||
defer { fragmentzip_close(fz) }
|
defer { fragmentzip_close(fz) }
|
||||||
|
|
||||||
self.progress.becomeCurrent(withPendingUnitCount: 100)
|
self.progress.becomeCurrent(withPendingUnitCount: 100)
|
||||||
fragmentzip_download_file(fz, update.archivePath, archivePath!, ALTFragmentZipCallback)
|
defer { self.progress.resignCurrent() }
|
||||||
self.progress.resignCurrent()
|
|
||||||
|
guard fragmentzip_download_file(fz, update.archivePath, archivePath!, ALTFragmentZipCallback) == 0 else {
|
||||||
|
throw URLError(.networkConnectionLost, userInfo: [NSLocalizedDescriptionKey: NSLocalizedString("The connection failed because the network connection was lost.", comment: ""),
|
||||||
|
NSURLErrorKey: update.url])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Downloaded OTA archive.")
|
print("Downloaded OTA archive.")
|
||||||
|
|||||||
Reference in New Issue
Block a user