@capgo/capacitor-updater 5.0.1 → 5.0.6
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.
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +12 -5
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +6 -2
- package/ios/Plugin/CapacitorUpdater.swift +17 -15
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +2 -2
- package/package.json +2 -2
|
@@ -488,8 +488,10 @@ public class CapacitorUpdater {
|
|
|
488
488
|
this.privateKey == null ||
|
|
489
489
|
this.privateKey.isEmpty() ||
|
|
490
490
|
ivSessionKey == null ||
|
|
491
|
-
ivSessionKey.isEmpty()
|
|
491
|
+
ivSessionKey.isEmpty() ||
|
|
492
|
+
ivSessionKey.split(":").length != 2
|
|
492
493
|
) {
|
|
494
|
+
Log.i(TAG, "Cannot found privateKey or sessionKey");
|
|
493
495
|
return;
|
|
494
496
|
}
|
|
495
497
|
try {
|
|
@@ -634,10 +636,15 @@ public class CapacitorUpdater {
|
|
|
634
636
|
private boolean bundleExists(final String id) {
|
|
635
637
|
final File bundle = this.getBundleDirectory(id);
|
|
636
638
|
final BundleInfo bundleInfo = this.getBundleInfo(id);
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
+
if (
|
|
640
|
+
bundle.isDirectory() &&
|
|
641
|
+
bundle.exists() &&
|
|
642
|
+
new File(bundle.getPath(), "/index.html").exists() &&
|
|
643
|
+
!bundleInfo.isDeleted()
|
|
644
|
+
) {
|
|
645
|
+
return true;
|
|
639
646
|
}
|
|
640
|
-
return
|
|
647
|
+
return false;
|
|
641
648
|
}
|
|
642
649
|
|
|
643
650
|
public Boolean set(final BundleInfo bundle) {
|
|
@@ -1000,7 +1007,7 @@ public class CapacitorUpdater {
|
|
|
1000
1007
|
if (id != null) {
|
|
1001
1008
|
trueId = id;
|
|
1002
1009
|
}
|
|
1003
|
-
Log.d(TAG, "Getting info for bundle [" + trueId + "]");
|
|
1010
|
+
// Log.d(TAG, "Getting info for bundle [" + trueId + "]");
|
|
1004
1011
|
BundleInfo result;
|
|
1005
1012
|
if (BundleInfo.ID_BUILTIN.equals(trueId)) {
|
|
1006
1013
|
result = new BundleInfo(trueId, null, BundleStatus.SUCCESS, "", "");
|
|
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin
|
|
|
55
55
|
private static final String channelUrlDefault =
|
|
56
56
|
"https://api.capgo.app/channel_self";
|
|
57
57
|
|
|
58
|
-
private final String PLUGIN_VERSION = "5.0.
|
|
58
|
+
private final String PLUGIN_VERSION = "5.0.6";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -228,7 +228,11 @@ public class CapacitorUpdaterPlugin
|
|
|
228
228
|
ret.put("bundle", bundleInfo.toJSON());
|
|
229
229
|
this.notifyListeners("download", ret);
|
|
230
230
|
if (percent == 100) {
|
|
231
|
-
|
|
231
|
+
final JSObject retDownloadComplete = new JSObject(
|
|
232
|
+
ret,
|
|
233
|
+
new String[] { "bundle" }
|
|
234
|
+
);
|
|
235
|
+
this.notifyListeners("downloadComplete", retDownloadComplete);
|
|
232
236
|
this.implementation.sendStats(
|
|
233
237
|
"download_complete",
|
|
234
238
|
bundleInfo.getVersionName()
|
|
@@ -348,7 +348,7 @@ extension CustomError: LocalizedError {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
private func decryptFile(filePath: URL, sessionKey: String, version: String) throws {
|
|
351
|
-
if self.privateKey.isEmpty || sessionKey.isEmpty {
|
|
351
|
+
if self.privateKey.isEmpty || sessionKey.isEmpty || sessionKey.components(separatedBy: ":").count != 2 {
|
|
352
352
|
print("\(self.TAG) Cannot found privateKey or sessionKey")
|
|
353
353
|
return
|
|
354
354
|
}
|
|
@@ -473,7 +473,7 @@ extension CustomError: LocalizedError {
|
|
|
473
473
|
let percent = self.calcTotalPercent(percent: Int(progress.fractionCompleted * 100), min: 10, max: 70)
|
|
474
474
|
self.notifyDownload(id, percent)
|
|
475
475
|
}
|
|
476
|
-
request.responseURL { (response) in
|
|
476
|
+
request.responseURL(queue: .global(qos: .background), completionHandler: { (response) in
|
|
477
477
|
if let fileURL = response.fileURL {
|
|
478
478
|
switch response.result {
|
|
479
479
|
case .success:
|
|
@@ -496,7 +496,7 @@ extension CustomError: LocalizedError {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
semaphore.signal()
|
|
499
|
-
}
|
|
499
|
+
})
|
|
500
500
|
self.saveBundleInfo(id: id, bundle: BundleInfo(id: id, version: version, status: BundleStatus.DOWNLOADING, downloaded: Date(), checksum: checksum))
|
|
501
501
|
self.notifyDownload(id, 0)
|
|
502
502
|
semaphore.wait()
|
|
@@ -559,6 +559,10 @@ extension CustomError: LocalizedError {
|
|
|
559
559
|
return self.delete(id: id, removeInfo: true)
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
+
public func getPathHot(id: String) -> URL {
|
|
563
|
+
return documentsDir.appendingPathComponent(self.bundleDirectoryHot).appendingPathComponent(id)
|
|
564
|
+
}
|
|
565
|
+
|
|
562
566
|
public func getBundleDirectory(id: String) -> URL {
|
|
563
567
|
return libraryDir.appendingPathComponent(self.bundleDirectory).appendingPathComponent(id)
|
|
564
568
|
}
|
|
@@ -569,12 +573,18 @@ extension CustomError: LocalizedError {
|
|
|
569
573
|
|
|
570
574
|
private func bundleExists(id: String) -> Bool {
|
|
571
575
|
let destHot: URL = self.getPathHot(id: id)
|
|
572
|
-
let destHotPersist: URL = self.
|
|
576
|
+
let destHotPersist: URL = self.getBundleDirectory(id: id)
|
|
573
577
|
let indexHot: URL = destHot.appendingPathComponent("index.html")
|
|
574
578
|
let indexPersist: URL = destHotPersist.appendingPathComponent("index.html")
|
|
575
|
-
let url: URL = self.getBundleDirectory(id: id)
|
|
576
579
|
let bundleIndo: BundleInfo = self.getBundleInfo(id: id)
|
|
577
|
-
if
|
|
580
|
+
if
|
|
581
|
+
destHot.exist &&
|
|
582
|
+
destHot.isDirectory &&
|
|
583
|
+
destHotPersist.exist &&
|
|
584
|
+
destHotPersist.isDirectory &&
|
|
585
|
+
indexHot.exist &&
|
|
586
|
+
indexPersist.exist &&
|
|
587
|
+
!bundleIndo.isDeleted() {
|
|
578
588
|
return true
|
|
579
589
|
}
|
|
580
590
|
return false
|
|
@@ -597,14 +607,6 @@ extension CustomError: LocalizedError {
|
|
|
597
607
|
return false
|
|
598
608
|
}
|
|
599
609
|
|
|
600
|
-
public func getPathHot(id: String) -> URL {
|
|
601
|
-
return documentsDir.appendingPathComponent(self.bundleDirectoryHot).appendingPathComponent(id)
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
public func getPathPersist(id: String) -> URL {
|
|
605
|
-
return libraryDir.appendingPathComponent(self.bundleDirectory).appendingPathComponent(id)
|
|
606
|
-
}
|
|
607
|
-
|
|
608
610
|
public func reset() {
|
|
609
611
|
self.reset(isInternal: false)
|
|
610
612
|
}
|
|
@@ -741,7 +743,7 @@ extension CustomError: LocalizedError {
|
|
|
741
743
|
if id != nil {
|
|
742
744
|
trueId = id!
|
|
743
745
|
}
|
|
744
|
-
print("\(self.TAG) Getting info for bundle [\(trueId)]")
|
|
746
|
+
// print("\(self.TAG) Getting info for bundle [\(trueId)]")
|
|
745
747
|
let result: BundleInfo
|
|
746
748
|
if BundleInfo.ID_BUILTIN == trueId {
|
|
747
749
|
result = BundleInfo(id: trueId, version: "", status: BundleStatus.SUCCESS, checksum: "")
|
|
@@ -15,7 +15,7 @@ import Version
|
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
17
17
|
private var implementation = CapacitorUpdater()
|
|
18
|
-
private let PLUGIN_VERSION: String = "5.0.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.0.6"
|
|
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"
|
|
@@ -531,7 +531,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
531
531
|
}
|
|
532
532
|
if latest!.isDownloaded() {
|
|
533
533
|
print("\(self.implementation.TAG) Latest version already exists and download is NOT required. Update will occur next time app moves to background.")
|
|
534
|
-
self.notifyListeners("updateAvailable", data: ["bundle":
|
|
534
|
+
self.notifyListeners("updateAvailable", data: ["bundle": latest!.toJSON()])
|
|
535
535
|
_ = self.implementation.setNextBundle(next: latest!.getId())
|
|
536
536
|
self.endBackGroundTask()
|
|
537
537
|
return
|
package/package.json
CHANGED