@capgo/capacitor-updater 4.0.0-alpha.21 → 4.0.0-alpha.24

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.
@@ -46,7 +46,7 @@ public class CapacitorUpdater {
46
46
  private static final String bundleDirectory = "versions";
47
47
 
48
48
  public static final String TAG = "Capacitor-updater";
49
- public static final String pluginVersion = "4.0.0-alpha.21";
49
+ public static final String pluginVersion = "4.0.0-alpha.24";
50
50
 
51
51
  public SharedPreferences.Editor editor;
52
52
  public SharedPreferences prefs;
@@ -98,7 +98,7 @@ public class CapacitorUpdater {
98
98
  this.notifyDownload(id, 75);
99
99
 
100
100
  ZipEntry entry;
101
- while ((entry = zis.getNextBundleEntry()) != null) {
101
+ while ((entry = zis.getNextEntry()) != null) {
102
102
  final File file = new File(targetDirectory, entry.getName());
103
103
  final String canonicalPath = file.getCanonicalPath();
104
104
  final String canonicalDir = (new File(String.valueOf(targetDirectory))).getCanonicalPath();
@@ -502,15 +502,12 @@ public class CapacitorUpdater {
502
502
  ? BundleInfo.ID_BUILTIN
503
503
  : fallback.getId()
504
504
  );
505
+ this.editor.commit();
505
506
  }
506
507
 
507
508
  public BundleInfo getNextBundle() {
508
- final String id = this.prefs.getString(NEXT_VERSION, "");
509
- if(id != "") {
510
- return this.getBundleInfo(id);
511
- } else {
512
- return null;
513
- }
509
+ final String id = this.prefs.getString(NEXT_VERSION, BundleInfo.ID_BUILTIN);
510
+ return this.getBundleInfo(id);
514
511
  }
515
512
 
516
513
  public boolean setNextBundle(final String next) {
@@ -518,11 +515,7 @@ public class CapacitorUpdater {
518
515
  this.editor.remove(NEXT_VERSION);
519
516
  } else {
520
517
  final BundleInfo newBundle = this.getBundleInfo(next);
521
- if(newBundle.isBuiltin()) {
522
- this.reset();
523
- return true;
524
- }
525
- if (!this.bundleExists(next)) {
518
+ if (!newBundle.isBuiltin() && !this.bundleExists(next)) {
526
519
  return false;
527
520
  }
528
521
  this.editor.putString(NEXT_VERSION, next);
@@ -88,6 +88,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
88
88
  this.implementation.editor = this.editor;
89
89
  this.implementation.versionOs = Build.VERSION.RELEASE;
90
90
  this.implementation.deviceID = Settings.Secure.getString(this.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
91
+ Log.e(CapacitorUpdater.TAG, "init for device", this.implementation.deviceID);
91
92
 
92
93
  this.autoDeleteFailed = this.getConfig().getBoolean("autoDeleteFailed", true);
93
94
  this.autoDeletePrevious = this.getConfig().getBoolean("autoDeletePrevious", true);
@@ -148,7 +148,7 @@ extension CustomError: LocalizedError {
148
148
 
149
149
  public let TAG = "✨ Capacitor-updater:";
150
150
  public let CAP_SERVER_PATH = "serverBasePath"
151
- public let pluginVersion = "4.0.0-alpha.21"
151
+ public let pluginVersion = "4.0.0-alpha.24"
152
152
  public var statsUrl = ""
153
153
  public var appId = ""
154
154
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
@@ -526,12 +526,8 @@ extension CustomError: LocalizedError {
526
526
  }
527
527
 
528
528
  public func getNextBundle() -> BundleInfo? {
529
- let id: String = UserDefaults.standard.string(forKey: self.NEXT_VERSION) ?? ""
530
- if(id != "") {
531
- return self.getBundleInfo(id: id)
532
- } else {
533
- return nil
534
- }
529
+ let id: String = UserDefaults.standard.string(forKey: self.NEXT_VERSION) ?? BundleInfo.ID_BUILTIN
530
+ return self.getBundleInfo(id: id)
535
531
  }
536
532
 
537
533
  public func setNextBundle(next: String?) -> Bool {
@@ -541,17 +537,13 @@ extension CustomError: LocalizedError {
541
537
  return false
542
538
  }
543
539
  let newBundle: BundleInfo = self.getBundleInfo(id: nextId)
544
- if(newBundle.isBuiltin()) {
545
- self.reset()
546
- return true
547
- }
548
540
  let bundle: URL = self.getBundleDirectory(id: nextId)
549
- if (!bundle.exist) {
541
+ if (!newBundle.isBuiltin() && !bundle.exist) {
550
542
  return false
551
543
  }
552
- UserDefaults.standard.set(next, forKey: self.NEXT_VERSION)
544
+ UserDefaults.standard.set(nextId, forKey: self.NEXT_VERSION)
553
545
  UserDefaults.standard.synchronize()
554
- self.setBundleStatus(id: next!, status: BundleStatus.PENDING)
546
+ self.setBundleStatus(id: nextId, status: BundleStatus.PENDING)
555
547
  return true
556
548
  }
557
549
  }
@@ -24,6 +24,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
24
24
  private var autoDeletePrevious = false
25
25
 
26
26
  override public func load() {
27
+ print("\(self.implementation.TAG) init for device \(self.implementation.deviceID)")
27
28
  do {
28
29
  currentVersionNative = try Version(Bundle.main.buildVersionNumber ?? "0.0.0")
29
30
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.0.0-alpha.21",
3
+ "version": "4.0.0-alpha.24",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",