@capgo/capacitor-updater 4.3.1 → 4.3.3
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/BundleInfo.java +5 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +7 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +21 -7
- package/ios/Plugin/BundleInfo.swift +5 -1
- package/ios/Plugin/BundleStatus.swift +1 -0
- package/ios/Plugin/CapacitorUpdater.swift +5 -3
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +9 -0
- package/package.json +1 -1
|
@@ -55,8 +55,12 @@ public class BundleInfo {
|
|
|
55
55
|
return BundleStatus.ERROR == this.status;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
public Boolean isDeleted() {
|
|
59
|
+
return BundleStatus.DELETED == this.status;
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
public boolean isDownloaded() {
|
|
59
|
-
return !this.isBuiltin() && this.downloaded != null && !this.downloaded.equals("");
|
|
63
|
+
return !this.isBuiltin() && this.downloaded != null && !this.downloaded.equals("") && !this.isDeleted();
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
public String getDownloaded() {
|
|
@@ -45,7 +45,7 @@ public class CapacitorUpdater {
|
|
|
45
45
|
private static final String bundleDirectory = "versions";
|
|
46
46
|
|
|
47
47
|
public static final String TAG = "Capacitor-updater";
|
|
48
|
-
public static final String pluginVersion = "4.3.
|
|
48
|
+
public static final String pluginVersion = "4.3.3";
|
|
49
49
|
|
|
50
50
|
public SharedPreferences.Editor editor;
|
|
51
51
|
public SharedPreferences prefs;
|
|
@@ -265,6 +265,8 @@ public class CapacitorUpdater {
|
|
|
265
265
|
this.deleteDirectory(bundle);
|
|
266
266
|
if (removeInfo) {
|
|
267
267
|
this.removeBundleInfo(id);
|
|
268
|
+
} else {
|
|
269
|
+
this.saveBundleInfo(id, deleted.setStatus(BundleStatus.DELETED));
|
|
268
270
|
}
|
|
269
271
|
return true;
|
|
270
272
|
}
|
|
@@ -283,7 +285,8 @@ public class CapacitorUpdater {
|
|
|
283
285
|
|
|
284
286
|
private boolean bundleExists(final String id) {
|
|
285
287
|
final File bundle = this.getBundleDirectory(id);
|
|
286
|
-
|
|
288
|
+
final BundleInfo bundleInfo = this.getBundleInfo(id);
|
|
289
|
+
if (bundle == null || !bundle.exists() || !bundleInfo.isDeleted()) {
|
|
287
290
|
return false;
|
|
288
291
|
}
|
|
289
292
|
return new File(bundle.getPath(), "/index.html").exists();
|
|
@@ -354,7 +357,7 @@ public class CapacitorUpdater {
|
|
|
354
357
|
final String versionCode = this.versionCode;
|
|
355
358
|
final String versionOs = this.versionOs;
|
|
356
359
|
final String pluginVersion = CapacitorUpdater.pluginVersion;
|
|
357
|
-
final String
|
|
360
|
+
final String versionName = this.getCurrentBundle().getVersionName();
|
|
358
361
|
try {
|
|
359
362
|
JSONObject json = new JSONObject();
|
|
360
363
|
json.put("platform", "android");
|
|
@@ -363,7 +366,7 @@ public class CapacitorUpdater {
|
|
|
363
366
|
json.put("version_build", versionBuild);
|
|
364
367
|
json.put("version_code", versionCode);
|
|
365
368
|
json.put("version_os", versionOs);
|
|
366
|
-
json.put("version_name",
|
|
369
|
+
json.put("version_name", versionName);
|
|
367
370
|
json.put("plugin_version", pluginVersion);
|
|
368
371
|
|
|
369
372
|
Log.i(CapacitorUpdater.TAG, "Auto-update parameters: " + json);
|
|
@@ -357,7 +357,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
357
357
|
}
|
|
358
358
|
call.resolve(ret);
|
|
359
359
|
}
|
|
360
|
-
|
|
360
|
+
);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
);
|
|
@@ -619,11 +619,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
619
619
|
|
|
620
620
|
if (
|
|
621
621
|
latestVersionName != null &&
|
|
622
|
-
|
|
623
|
-
|
|
622
|
+
!"".equals(latestVersionName) &&
|
|
623
|
+
!current.getVersionName().equals(latestVersionName)
|
|
624
624
|
) {
|
|
625
625
|
final BundleInfo latest =
|
|
626
|
-
|
|
626
|
+
CapacitorUpdaterPlugin.this.implementation.getBundleInfoByName(latestVersionName);
|
|
627
627
|
if (latest != null) {
|
|
628
628
|
if (latest.isErrorStatus()) {
|
|
629
629
|
Log.e(
|
|
@@ -646,6 +646,20 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
646
646
|
CapacitorUpdaterPlugin.this.implementation.setNextBundle(latest.getId());
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
|
+
if (latest.isDeleted()) {
|
|
650
|
+
Log.i(
|
|
651
|
+
CapacitorUpdater.TAG,
|
|
652
|
+
"Latest bundle already exists and will be deleted, download will overwrite it."
|
|
653
|
+
);
|
|
654
|
+
try {
|
|
655
|
+
final Boolean deleted = CapacitorUpdaterPlugin.this.implementation.delete(latest.getId(), true);
|
|
656
|
+
if (deleted) {
|
|
657
|
+
Log.i(CapacitorUpdater.TAG, "Failed bundle deleted: " + latest.getVersionName());
|
|
658
|
+
}
|
|
659
|
+
} catch (final IOException e) {
|
|
660
|
+
Log.e(CapacitorUpdater.TAG, "Failed to delete failed bundle: " + latest.getVersionName(), e);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
649
663
|
}
|
|
650
664
|
|
|
651
665
|
new Thread(
|
|
@@ -695,7 +709,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
695
709
|
CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
|
|
696
710
|
}
|
|
697
711
|
}
|
|
698
|
-
|
|
712
|
+
);
|
|
699
713
|
}
|
|
700
714
|
}
|
|
701
715
|
)
|
|
@@ -820,8 +834,8 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
820
834
|
public void run() {
|
|
821
835
|
try {
|
|
822
836
|
Log.i(
|
|
823
|
-
|
|
824
|
-
|
|
837
|
+
CapacitorUpdater.TAG,
|
|
838
|
+
"Wait for " + CapacitorUpdaterPlugin.this.appReadyTimeout + "ms, then check for notifyAppReady"
|
|
825
839
|
);
|
|
826
840
|
Thread.sleep(CapacitorUpdaterPlugin.this.appReadyTimeout);
|
|
827
841
|
CapacitorUpdaterPlugin.this.checkRevert();
|
|
@@ -39,8 +39,12 @@ import Foundation
|
|
|
39
39
|
return BundleStatus.ERROR == self.status
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
public func isDeleted() -> Bool {
|
|
43
|
+
return BundleStatus.DELETED == self.status
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
public func isDownloaded() -> Bool {
|
|
43
|
-
return !self.isBuiltin() && self.downloaded != "" && self.downloaded != BundleInfo.DOWNLOADED_BUILTIN
|
|
47
|
+
return !self.isBuiltin() && self.downloaded != "" && self.downloaded != BundleInfo.DOWNLOADED_BUILTIN && !self.isDeleted()
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
public func getDownloaded() -> String {
|
|
@@ -146,7 +146,7 @@ extension CustomError: LocalizedError {
|
|
|
146
146
|
|
|
147
147
|
public let TAG = "✨ Capacitor-updater:"
|
|
148
148
|
public let CAP_SERVER_PATH = "serverBasePath"
|
|
149
|
-
public let pluginVersion = "4.3.
|
|
149
|
+
public let pluginVersion = "4.3.3"
|
|
150
150
|
public var statsUrl = ""
|
|
151
151
|
public var appId = ""
|
|
152
152
|
public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
@@ -362,8 +362,9 @@ extension CustomError: LocalizedError {
|
|
|
362
362
|
}
|
|
363
363
|
if removeInfo {
|
|
364
364
|
self.removeBundleInfo(id: id)
|
|
365
|
+
} else {
|
|
366
|
+
self.saveBundleInfo(id: id, bundle: deleted.setStatus(status: BundleStatus.DELETED.localizedString))
|
|
365
367
|
}
|
|
366
|
-
self.removeBundleInfo(id: id)
|
|
367
368
|
self.sendStats(action: "delete", versionName: deleted.getVersionName())
|
|
368
369
|
return true
|
|
369
370
|
}
|
|
@@ -386,7 +387,8 @@ extension CustomError: LocalizedError {
|
|
|
386
387
|
let indexHot = destHot.appendingPathComponent("index.html")
|
|
387
388
|
let indexPersist = destHotPersist.appendingPathComponent("index.html")
|
|
388
389
|
let url: URL = self.getBundleDirectory(id: id)
|
|
389
|
-
|
|
390
|
+
let bundleIndo: BundleInfo = self.getBundleInfo(id: id)
|
|
391
|
+
if url.isDirectory && destHotPersist.isDirectory && indexHot.exist && indexPersist.exist && !bundleIndo.isDeleted() {
|
|
390
392
|
return true
|
|
391
393
|
}
|
|
392
394
|
return false
|
|
@@ -451,6 +451,15 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
451
451
|
_ = self.implementation.setNextBundle(next: latest!.getId())
|
|
452
452
|
return
|
|
453
453
|
}
|
|
454
|
+
if latest!.isDeleted() {
|
|
455
|
+
print("\(self.implementation.TAG) Latest bundle already exists and will be deleted, download will overwrite it.")
|
|
456
|
+
let res = self.implementation.delete(id: latest!.getId(), removeInfo: true)
|
|
457
|
+
if !res {
|
|
458
|
+
print("\(self.implementation.TAG) Delete version deleted: \(latest!.toString())")
|
|
459
|
+
} else {
|
|
460
|
+
print("\(self.implementation.TAG) Failed to delete failed bundle: \(latest!.toString())")
|
|
461
|
+
}
|
|
462
|
+
}
|
|
454
463
|
}
|
|
455
464
|
|
|
456
465
|
do {
|