@capgo/capacitor-updater 6.1.3 → 6.1.4

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.
@@ -56,7 +56,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
56
56
  private static final String channelUrlDefault =
57
57
  "https://api.capgo.app/channel_self";
58
58
 
59
- private final String PLUGIN_VERSION = "6.1.3";
59
+ private final String PLUGIN_VERSION = "6.1.4";
60
60
  private static final String DELAY_CONDITION_PREFERENCES = "";
61
61
 
62
62
  private SharedPreferences.Editor editor;
@@ -630,11 +630,13 @@ extension CustomError: LocalizedError {
630
630
  saveDownloadInfo(version)
631
631
  var checksum = ""
632
632
  var targetSize = -1
633
- var lastSentProgress = 0;
633
+ var lastSentProgress = 0
634
634
  var totalReceivedBytes: Int64 = loadDownloadProgress() //Retrieving the amount of already downloaded data if exist, defined at 0 otherwise
635
635
  let requestHeaders: HTTPHeaders = ["Range": "bytes=\(totalReceivedBytes)-"]
636
636
  //Opening connection for streaming the bytes
637
-
637
+ if(totalReceivedBytes == 0){
638
+ self.notifyDownload(id: id, percent: 0, ignoreMultipleOfTen: true)
639
+ }
638
640
  var mainError: NSError?
639
641
  let monitor = ClosureEventMonitor()
640
642
  monitor.requestDidCompleteTaskWithError = { (request, task, error) in
@@ -648,13 +650,10 @@ extension CustomError: LocalizedError {
648
650
  var request = session.streamRequest(url, headers: requestHeaders).validate().onHTTPResponse(perform: { response in
649
651
  if let contentLength = response.headers.value(for: "Content-Length") {
650
652
  targetSize = (Int(contentLength) ?? -1) + Int(totalReceivedBytes)
651
- lastSentProgress = Int((Double(totalReceivedBytes) / Double(targetSize)) * 100.0)
652
653
  }
653
654
  }).responseStream { [weak self] streamResponse in
654
655
  guard let self = self else { return }
655
-
656
656
  switch streamResponse.event {
657
-
658
657
  case .stream(let result):
659
658
  if case .success(let data) = result {
660
659
  self.tempData.append(data)
@@ -663,12 +662,16 @@ extension CustomError: LocalizedError {
663
662
  totalReceivedBytes += Int64(data.count)
664
663
 
665
664
  let percent = Int((Double(totalReceivedBytes) / Double(targetSize)) * 100.0)
665
+
666
666
  print("\(self.TAG) Downloading: \(percent)%")
667
- if (percent - lastSentProgress >= 10) {
668
- self.notifyDownload(id: id, percent: percent, ignoreMultipleOfTen: true)
669
- lastSentProgress = percent
670
- }
671
- // usleep(useconds_t(2000 * 1000))
667
+ let currentMilestone = (percent / 10) * 10
668
+ if currentMilestone > lastSentProgress && currentMilestone <= 70 {
669
+ for milestone in stride(from: lastSentProgress + 10, through: currentMilestone, by: 10) {
670
+ self.notifyDownload(id: id, percent: milestone, ignoreMultipleOfTen: true)
671
+ }
672
+ lastSentProgress = currentMilestone
673
+ }
674
+
672
675
  }
673
676
  else {
674
677
  print("\(self.TAG) Download failed")
@@ -16,7 +16,7 @@ import SwiftyRSA
16
16
  @objc(CapacitorUpdaterPlugin)
17
17
  public class CapacitorUpdaterPlugin: CAPPlugin {
18
18
  public var implementation = CapacitorUpdater()
19
- private let PLUGIN_VERSION: String = "6.1.3"
19
+ private let PLUGIN_VERSION: String = "6.1.4"
20
20
  static let updateUrlDefault = "https://api.capgo.app/updates"
21
21
  static let statsUrlDefault = "https://api.capgo.app/stats"
22
22
  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": "6.1.3",
3
+ "version": "6.1.4",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",