@capgo/capacitor-updater 5.7.0 → 5.7.2

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.
@@ -298,6 +298,7 @@ public class CapacitorUpdater {
298
298
  String version = bundle.getString(DownloadService.VERSION);
299
299
  String sessionKey = bundle.getString(DownloadService.SESSIONKEY);
300
300
  String checksum = bundle.getString(DownloadService.CHECKSUM);
301
+ String error = bundle.getString(DownloadService.ERROR);
301
302
  Log.i(
302
303
  CapacitorUpdater.TAG,
303
304
  "res " +
@@ -309,7 +310,9 @@ public class CapacitorUpdater {
309
310
  " " +
310
311
  sessionKey +
311
312
  " " +
312
- checksum
313
+ checksum +
314
+ " " +
315
+ error
313
316
  );
314
317
  if (dest == null) {
315
318
  final JSObject ret = new JSObject();
@@ -317,8 +320,12 @@ public class CapacitorUpdater {
317
320
  "version",
318
321
  CapacitorUpdater.this.getCurrentBundle().getVersionName()
319
322
  );
323
+ if ("low_mem_fail".equals(error)) {
324
+ CapacitorUpdater.this.sendStats("low_mem_fail", version);
325
+ }
326
+ ret.put("error", "download_fail");
327
+ CapacitorUpdater.this.sendStats("download_fail", version);
320
328
  CapacitorUpdater.this.notifyListeners("downloadFailed", ret);
321
- CapacitorUpdater.this.sendStats("download_fail");
322
329
  return;
323
330
  }
324
331
  CapacitorUpdater.this.finishDownload(
@@ -465,6 +472,10 @@ public class CapacitorUpdater {
465
472
  }
466
473
  bytesRead += length;
467
474
  }
475
+ } catch (OutOfMemoryError e) {
476
+ Log.e(TAG, "OutOfMemoryError while downloading file", e);
477
+ this.sendStats("low_mem_fail");
478
+ throw new IOException("OutOfMemoryError while downloading file");
468
479
  }
469
480
  return target;
470
481
  }
@@ -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.0";
58
+ private final String PLUGIN_VERSION = "5.7.2";
59
59
  private static final String DELAY_CONDITION_PREFERENCES = "";
60
60
 
61
61
  private SharedPreferences.Editor editor;
@@ -822,6 +822,9 @@ public class CapacitorUpdaterPlugin extends Plugin {
822
822
  if (this.periodCheckDelay == 0 || !this._isAutoUpdateEnabled()) {
823
823
  return;
824
824
  }
825
+ // The delay should be equal to this.periodCheckDelay.
826
+ // In appMovedToForeground we schedule a backgroundDownload and it happens BEFORE this scheduleAtFixedRate
827
+ // As such we get a race condition
825
828
  final Timer timer = new Timer();
826
829
  timer.scheduleAtFixedRate(
827
830
  new TimerTask() {
@@ -854,7 +857,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
854
857
  }
855
858
  }
856
859
  },
857
- 0,
860
+ this.periodCheckDelay,
858
861
  this.periodCheckDelay
859
862
  );
860
863
  }
@@ -84,6 +84,9 @@ public class DownloadService extends IntentService {
84
84
  publishResults(dest, id, version, checksum, sessionKey, "");
85
85
  }
86
86
  }
87
+ } catch (OutOfMemoryError e) {
88
+ e.printStackTrace();
89
+ publishResults("", id, version, checksum, sessionKey, "low_mem_fail");
87
90
  } catch (Exception e) {
88
91
  e.printStackTrace();
89
92
  publishResults(
@@ -527,6 +527,11 @@ extension CustomError: LocalizedError {
527
527
  }
528
528
  case let .failure(error):
529
529
  print("\(self.TAG) download error", response.value ?? "", error)
530
+ if let afError = error as? AFError,
531
+ case .sessionTaskFailed(let urlError as URLError) = afError,
532
+ urlError.code == .cannotWriteToFile {
533
+ self.sendStats(action: "low_mem_fail", versionName: version)
534
+ }
530
535
  mainError = error as NSError
531
536
  }
532
537
  }
@@ -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.0"
18
+ private let PLUGIN_VERSION: String = "5.7.2"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "packageManager": "pnpm@8.15.4",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",