@capgo/capacitor-updater 5.7.18 → 5.7.20
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.
|
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
55
55
|
private static final String channelUrlDefault =
|
|
56
56
|
"https://api.capgo.app/channel_self";
|
|
57
57
|
|
|
58
|
-
private final String PLUGIN_VERSION = "5.7.
|
|
58
|
+
private final String PLUGIN_VERSION = "5.7.20";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -366,7 +366,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
366
366
|
@PluginMethod
|
|
367
367
|
public void setUpdateUrl(final PluginCall call) {
|
|
368
368
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
369
|
-
Log.e(
|
|
369
|
+
Log.e(
|
|
370
|
+
CapacitorUpdater.TAG,
|
|
371
|
+
"setUpdateUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
372
|
+
);
|
|
370
373
|
call.reject("setUpdateUrl not allowed");
|
|
371
374
|
return;
|
|
372
375
|
}
|
|
@@ -383,7 +386,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
383
386
|
@PluginMethod
|
|
384
387
|
public void setStatsUrl(final PluginCall call) {
|
|
385
388
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
386
|
-
Log.e(
|
|
389
|
+
Log.e(
|
|
390
|
+
CapacitorUpdater.TAG,
|
|
391
|
+
"setStatsUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
392
|
+
);
|
|
387
393
|
call.reject("setStatsUrl not allowed");
|
|
388
394
|
return;
|
|
389
395
|
}
|
|
@@ -400,7 +406,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
400
406
|
@PluginMethod
|
|
401
407
|
public void setChannelUrl(final PluginCall call) {
|
|
402
408
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
403
|
-
Log.e(
|
|
409
|
+
Log.e(
|
|
410
|
+
CapacitorUpdater.TAG,
|
|
411
|
+
"setChannelUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
412
|
+
);
|
|
404
413
|
call.reject("setChannelUrl not allowed");
|
|
405
414
|
return;
|
|
406
415
|
}
|
|
@@ -436,14 +436,14 @@ extension CustomError: LocalizedError {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
let newPercent = Int(Double(entryNumber) / Double(total) * 100)
|
|
439
|
+
let newPercent = self.calcTotalPercent(percent: Int(Double(entryNumber) / Double(total) * 100), min: 75, max: 81)
|
|
440
440
|
if newPercent != self.unzipPercent {
|
|
441
441
|
self.unzipPercent = newPercent
|
|
442
|
-
self.notifyDownload(id,
|
|
442
|
+
self.notifyDownload(id, newPercent)
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
private func saveDownloaded(sourceZip: URL, id: String, base: URL) throws {
|
|
446
|
+
private func saveDownloaded(sourceZip: URL, id: String, base: URL, notify: Bool) throws {
|
|
447
447
|
try prepareFolder(source: base)
|
|
448
448
|
let destHot: URL = base.appendingPathComponent(id)
|
|
449
449
|
let destUnZip: URL = documentsDir.appendingPathComponent(randomString(length: 10))
|
|
@@ -451,7 +451,9 @@ extension CustomError: LocalizedError {
|
|
|
451
451
|
self.unzipPercent = 0
|
|
452
452
|
self.notifyDownload(id, 75)
|
|
453
453
|
|
|
454
|
+
let semaphore = DispatchSemaphore(value: 0)
|
|
454
455
|
var unzipError: NSError?
|
|
456
|
+
|
|
455
457
|
let success = SSZipArchive.unzipFile(atPath: sourceZip.path,
|
|
456
458
|
toDestination: destUnZip.path,
|
|
457
459
|
preserveAttributes: true,
|
|
@@ -461,10 +463,19 @@ extension CustomError: LocalizedError {
|
|
|
461
463
|
error: &unzipError,
|
|
462
464
|
delegate: nil,
|
|
463
465
|
progressHandler: { [weak self] (entry, zipInfo, entryNumber, total) in
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
DispatchQueue.global(qos: .background).async {
|
|
467
|
+
guard let self = self else { return }
|
|
468
|
+
if !notify {
|
|
469
|
+
return
|
|
470
|
+
}
|
|
471
|
+
self.unzipProgressHandler(entry: entry, zipInfo: zipInfo, entryNumber: entryNumber, total: total, destUnZip: destUnZip, id: id, unzipError: &unzipError)
|
|
472
|
+
}
|
|
466
473
|
},
|
|
467
|
-
completionHandler:
|
|
474
|
+
completionHandler: { _, _, _ in
|
|
475
|
+
semaphore.signal()
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
semaphore.wait()
|
|
468
479
|
|
|
469
480
|
if !success || unzipError != nil {
|
|
470
481
|
self.sendStats(action: "unzip_fail")
|
|
@@ -475,6 +486,7 @@ extension CustomError: LocalizedError {
|
|
|
475
486
|
try deleteFolder(source: destUnZip)
|
|
476
487
|
}
|
|
477
488
|
}
|
|
489
|
+
|
|
478
490
|
private func createInfoObject() -> InfoObject {
|
|
479
491
|
return InfoObject(
|
|
480
492
|
platform: "ios",
|
|
@@ -571,11 +583,10 @@ extension CustomError: LocalizedError {
|
|
|
571
583
|
do {
|
|
572
584
|
try self.decryptFile(filePath: fileURL, sessionKey: sessionKey, version: version)
|
|
573
585
|
checksum = self.getChecksum(filePath: fileURL)
|
|
574
|
-
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.documentsDir.appendingPathComponent(self.bundleDirectoryHot))
|
|
575
|
-
self.
|
|
576
|
-
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory))
|
|
577
|
-
self.notifyDownload(id, 100)
|
|
586
|
+
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.documentsDir.appendingPathComponent(self.bundleDirectoryHot), notify: true)
|
|
587
|
+
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory), notify: false)
|
|
578
588
|
try self.deleteFolder(source: fileURL)
|
|
589
|
+
self.notifyDownload(id, 100)
|
|
579
590
|
} catch {
|
|
580
591
|
print("\(self.TAG) download unzip error", error)
|
|
581
592
|
mainError = error as NSError
|
|
@@ -15,7 +15,7 @@ import Version
|
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
17
17
|
public var implementation = CapacitorUpdater()
|
|
18
|
-
private let PLUGIN_VERSION: String = "5.7.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.7.20"
|
|
19
19
|
static let updateUrlDefault = "https://api.capgo.app/updates"
|
|
20
20
|
static let statsUrlDefault = "https://api.capgo.app/stats"
|
|
21
21
|
static let channelUrlDefault = "https://api.capgo.app/channel_self"
|
|
@@ -143,9 +143,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
@objc func setUpdateUrl(_ call: CAPPluginCall) {
|
|
146
|
-
if !
|
|
146
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
147
147
|
print("\(self.implementation.TAG) setUpdateUrl called without allowModifyUrl")
|
|
148
|
-
call.reject("setUpdateUrl called without allowModifyUrl")
|
|
148
|
+
call.reject("setUpdateUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
149
149
|
return
|
|
150
150
|
}
|
|
151
151
|
guard let url = call.getString("url") else {
|
|
@@ -158,9 +158,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
@objc func setStatsUrl(_ call: CAPPluginCall) {
|
|
161
|
-
if !
|
|
161
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
162
162
|
print("\(self.implementation.TAG) setStatsUrl called without allowModifyUrl")
|
|
163
|
-
call.reject("setStatsUrl called without allowModifyUrl")
|
|
163
|
+
call.reject("setStatsUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
164
164
|
return
|
|
165
165
|
}
|
|
166
166
|
guard let url = call.getString("url") else {
|
|
@@ -173,9 +173,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
@objc func setChannelUrl(_ call: CAPPluginCall) {
|
|
176
|
-
if !
|
|
176
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
177
177
|
print("\(self.implementation.TAG) setChannelUrl called without allowModifyUrl")
|
|
178
|
-
call.reject("setChannelUrl called without allowModifyUrl")
|
|
178
|
+
call.reject("setChannelUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
179
179
|
return
|
|
180
180
|
}
|
|
181
181
|
guard let url = call.getString("url") else {
|