pulse-updates 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -68,7 +68,7 @@ public final class PulseController {
|
|
|
68
68
|
|
|
69
69
|
// Cached manifest from last check (to avoid duplicate requests in fetch)
|
|
70
70
|
// Only valid for the immediate check->fetch sequence, cleared on use or new check
|
|
71
|
-
private var lastCheckManifest:
|
|
71
|
+
private var lastCheckManifest: PulseManifestModel?
|
|
72
72
|
|
|
73
73
|
// MARK: - Native Config (from Info.plist, like expo-updates)
|
|
74
74
|
|
|
@@ -408,12 +408,12 @@ public final class PulseController {
|
|
|
408
408
|
private func performBackgroundUpdateCheck() {
|
|
409
409
|
pulseLog("Performing background update check")
|
|
410
410
|
|
|
411
|
-
checkForUpdate { [weak self] result in
|
|
411
|
+
checkForUpdate { [weak self] (result: Result<PulseCheckResult, Error>) in
|
|
412
412
|
switch result {
|
|
413
413
|
case .success(let checkResult):
|
|
414
414
|
if checkResult.isAvailable {
|
|
415
415
|
pulseLog("Background check: update available, fetching...")
|
|
416
|
-
self?.fetchUpdate { fetchResult in
|
|
416
|
+
self?.fetchUpdate { (fetchResult: Result<PulseFetchResult, Error>) in
|
|
417
417
|
switch fetchResult {
|
|
418
418
|
case .success(let fetch):
|
|
419
419
|
if fetch.isNew {
|
|
@@ -485,7 +485,7 @@ public final class PulseController {
|
|
|
485
485
|
PulseRemoteLoader.checkForUpdate(
|
|
486
486
|
config: config,
|
|
487
487
|
currentUpdateId: launchedUpdate?.updateId
|
|
488
|
-
) { [weak self] result in
|
|
488
|
+
) { [weak self] (result: Result<PulseCheckResult, Error>) in
|
|
489
489
|
// Cache the manifest for subsequent fetchUpdate call
|
|
490
490
|
if case .success(let checkResult) = result, checkResult.isAvailable {
|
|
491
491
|
self?.lastCheckManifest = checkResult.manifest
|
|
@@ -496,7 +496,7 @@ public final class PulseController {
|
|
|
496
496
|
|
|
497
497
|
/// Fetch and download an update
|
|
498
498
|
/// - Parameter cachedManifest: Optional manifest from a previous checkForUpdate call to avoid duplicate request
|
|
499
|
-
public func fetchUpdate(cachedManifest:
|
|
499
|
+
public func fetchUpdate(cachedManifest: PulseManifestModel? = nil, completion: @escaping (Result<PulseFetchResult, Error>) -> Void) {
|
|
500
500
|
guard let config = config else {
|
|
501
501
|
completion(.failure(PulseUpdatesError.notConfigured))
|
|
502
502
|
return
|
|
@@ -685,7 +685,7 @@ public final class PulseController {
|
|
|
685
685
|
|
|
686
686
|
self.launcher = launcher
|
|
687
687
|
|
|
688
|
-
launcher.launch { [weak self] success, error in
|
|
688
|
+
launcher.launch { [weak self] (success: Bool, error: Error?) in
|
|
689
689
|
guard let self = self else {
|
|
690
690
|
completion(false)
|
|
691
691
|
return
|
|
@@ -955,13 +955,13 @@ final class PulseRemoteLoader {
|
|
|
955
955
|
config: PulseUpdatesConfig,
|
|
956
956
|
database: PulseDatabase?,
|
|
957
957
|
directory: URL,
|
|
958
|
-
cachedManifest:
|
|
958
|
+
cachedManifest: PulseManifestModel? = nil,
|
|
959
959
|
completion: @escaping (Result<PulseFetchResult, Error>) -> Void
|
|
960
960
|
) {
|
|
961
961
|
// If we already have a manifest from a previous check, use it directly
|
|
962
962
|
if let manifest = cachedManifest {
|
|
963
963
|
pulseLog("fetchUpdate: using cached manifest, skipping check")
|
|
964
|
-
downloadUpdate(manifest: manifest, config: config, database: database, directory: directory) { downloadResult in
|
|
964
|
+
downloadUpdate(manifest: manifest, config: config, database: database, directory: directory) { (downloadResult: Result<Void, Error>) in
|
|
965
965
|
switch downloadResult {
|
|
966
966
|
case .failure(let error):
|
|
967
967
|
completion(.failure(error))
|
|
@@ -973,7 +973,7 @@ final class PulseRemoteLoader {
|
|
|
973
973
|
}
|
|
974
974
|
|
|
975
975
|
// No cached manifest, need to check first
|
|
976
|
-
checkForUpdate(config: config, currentUpdateId: PulseController.shared.launchedUpdate?.updateId) { result in
|
|
976
|
+
checkForUpdate(config: config, currentUpdateId: PulseController.shared.launchedUpdate?.updateId) { (result: Result<PulseCheckResult, Error>) in
|
|
977
977
|
switch result {
|
|
978
978
|
case .failure(let error):
|
|
979
979
|
completion(.failure(error))
|
|
@@ -985,7 +985,7 @@ final class PulseRemoteLoader {
|
|
|
985
985
|
}
|
|
986
986
|
|
|
987
987
|
// Download the update
|
|
988
|
-
downloadUpdate(manifest: manifest, config: config, database: database, directory: directory) { downloadResult in
|
|
988
|
+
downloadUpdate(manifest: manifest, config: config, database: database, directory: directory) { (downloadResult: Result<Void, Error>) in
|
|
989
989
|
switch downloadResult {
|
|
990
990
|
case .failure(let error):
|
|
991
991
|
completion(.failure(error))
|
|
@@ -1058,7 +1058,7 @@ final class PulseRemoteLoader {
|
|
|
1058
1058
|
try? database?.addUpdate(update)
|
|
1059
1059
|
|
|
1060
1060
|
// Download bundle
|
|
1061
|
-
downloadBundle(manifest: manifest, directory: directory, stagingDir: stagingDir, database: database, updateId: updateId) { bundleResult in
|
|
1061
|
+
downloadBundle(manifest: manifest, directory: directory, stagingDir: stagingDir, database: database, updateId: updateId) { (bundleResult: Result<Void, Error>) in
|
|
1062
1062
|
switch bundleResult {
|
|
1063
1063
|
case .failure(let error):
|
|
1064
1064
|
try? database?.setStatus(.failed, forUpdateId: updateId)
|
|
@@ -1067,7 +1067,7 @@ final class PulseRemoteLoader {
|
|
|
1067
1067
|
|
|
1068
1068
|
case .success:
|
|
1069
1069
|
// Download assets
|
|
1070
|
-
downloadAssets(manifest: manifest, directory: directory, stagingDir: stagingDir, database: database, updateId: updateId) { assetsResult in
|
|
1070
|
+
downloadAssets(manifest: manifest, directory: directory, stagingDir: stagingDir, database: database, updateId: updateId) { (assetsResult: Result<Void, Error>) in
|
|
1071
1071
|
switch assetsResult {
|
|
1072
1072
|
case .failure(let error):
|
|
1073
1073
|
try? database?.setStatus(.failed, forUpdateId: updateId)
|
|
@@ -1121,7 +1121,7 @@ final class PulseRemoteLoader {
|
|
|
1121
1121
|
|
|
1122
1122
|
let tempPath = stagingDir.appendingPathComponent("bundle.tmp")
|
|
1123
1123
|
|
|
1124
|
-
downloadFile(from: url, to: tempPath) { result in
|
|
1124
|
+
downloadFile(from: url, to: tempPath) { (result: Result<Void, Error>) in
|
|
1125
1125
|
switch result {
|
|
1126
1126
|
case .failure(let error):
|
|
1127
1127
|
completion(.failure(error))
|
|
@@ -1197,7 +1197,7 @@ final class PulseRemoteLoader {
|
|
|
1197
1197
|
|
|
1198
1198
|
let tempPath = stagingDir.appendingPathComponent("asset-\(assetHash).tmp")
|
|
1199
1199
|
|
|
1200
|
-
downloadFile(from: url, to: tempPath) { result in
|
|
1200
|
+
downloadFile(from: url, to: tempPath) { (result: Result<Void, Error>) in
|
|
1201
1201
|
switch result {
|
|
1202
1202
|
case .failure(let error):
|
|
1203
1203
|
downloadError = error
|