@capgo/capacitor-updater 5.7.18 → 5.7.19

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.
@@ -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.18";
58
+ private final String PLUGIN_VERSION = "5.7.19";
59
59
  private static final String DELAY_CONDITION_PREFERENCES = "";
60
60
 
61
61
  private SharedPreferences.Editor editor;
@@ -436,14 +436,14 @@ extension CustomError: LocalizedError {
436
436
  }
437
437
  }
438
438
 
439
- let newPercent = Int(Double(entryNumber) / Double(total) * 100)
439
+ let newPercent = self.calcTotalPercent(percent: Int(Double(entryNumber) / Double(total) * 100), min: 75, max: 81)
440
440
  if newPercent != self.unzipPercent {
441
441
  self.unzipPercent = newPercent
442
- self.notifyDownload(id, self.calcTotalPercent(percent: self.unzipPercent, min: 75, max: 90))
442
+ self.notifyDownload(id, newPercent)
443
443
  }
444
444
  }
445
445
 
446
- private func saveDownloaded(sourceZip: URL, id: String, base: URL) throws {
446
+ private func saveDownloaded(sourceZip: URL, id: String, base: URL, notify: Bool) throws {
447
447
  try prepareFolder(source: base)
448
448
  let destHot: URL = base.appendingPathComponent(id)
449
449
  let destUnZip: URL = documentsDir.appendingPathComponent(randomString(length: 10))
@@ -451,7 +451,9 @@ extension CustomError: LocalizedError {
451
451
  self.unzipPercent = 0
452
452
  self.notifyDownload(id, 75)
453
453
 
454
+ let semaphore = DispatchSemaphore(value: 0)
454
455
  var unzipError: NSError?
456
+
455
457
  let success = SSZipArchive.unzipFile(atPath: sourceZip.path,
456
458
  toDestination: destUnZip.path,
457
459
  preserveAttributes: true,
@@ -461,10 +463,19 @@ extension CustomError: LocalizedError {
461
463
  error: &unzipError,
462
464
  delegate: nil,
463
465
  progressHandler: { [weak self] (entry, zipInfo, entryNumber, total) in
464
- guard let self = self else { return }
465
- self.unzipProgressHandler(entry: entry, zipInfo: zipInfo, entryNumber: entryNumber, total: total, destUnZip: destUnZip, id: id, unzipError: &unzipError)
466
+ DispatchQueue.global(qos: .background).async {
467
+ guard let self = self else { return }
468
+ if !notify {
469
+ return
470
+ }
471
+ self.unzipProgressHandler(entry: entry, zipInfo: zipInfo, entryNumber: entryNumber, total: total, destUnZip: destUnZip, id: id, unzipError: &unzipError)
472
+ }
466
473
  },
467
- completionHandler: nil)
474
+ completionHandler: { _, _, _ in
475
+ semaphore.signal()
476
+ })
477
+
478
+ semaphore.wait()
468
479
 
469
480
  if !success || unzipError != nil {
470
481
  self.sendStats(action: "unzip_fail")
@@ -475,6 +486,7 @@ extension CustomError: LocalizedError {
475
486
  try deleteFolder(source: destUnZip)
476
487
  }
477
488
  }
489
+
478
490
  private func createInfoObject() -> InfoObject {
479
491
  return InfoObject(
480
492
  platform: "ios",
@@ -571,11 +583,10 @@ extension CustomError: LocalizedError {
571
583
  do {
572
584
  try self.decryptFile(filePath: fileURL, sessionKey: sessionKey, version: version)
573
585
  checksum = self.getChecksum(filePath: fileURL)
574
- try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.documentsDir.appendingPathComponent(self.bundleDirectoryHot))
575
- self.notifyDownload(id, 85)
576
- try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory))
577
- self.notifyDownload(id, 100)
586
+ try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.documentsDir.appendingPathComponent(self.bundleDirectoryHot), notify: true)
587
+ try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory), notify: false)
578
588
  try self.deleteFolder(source: fileURL)
589
+ self.notifyDownload(id, 100)
579
590
  } catch {
580
591
  print("\(self.TAG) download unzip error", error)
581
592
  mainError = error as NSError
@@ -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.18"
18
+ private let PLUGIN_VERSION: String = "5.7.19"
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.18",
3
+ "version": "5.7.19",
4
4
  "packageManager": "pnpm@8.15.4",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",