@capgo/capacitor-updater 5.30.0 → 5.31.0

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.
@@ -71,7 +71,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
71
71
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
72
72
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
73
73
 
74
- private final String pluginVersion = "5.30.0";
74
+ private final String pluginVersion = "5.31.0";
75
75
  private static final String DELAY_CONDITION_PREFERENCES = "";
76
76
 
77
77
  private SharedPreferences.Editor editor;
@@ -703,6 +703,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
703
703
  }
704
704
  }
705
705
  this.implementation.cleanupDownloadDirectories(allowedIds);
706
+ this.implementation.cleanupDeltaCache();
706
707
  }
707
708
  this.editor.putString("LatestNativeBuildVersion", this.currentBuildVersion);
708
709
  this.editor.apply();
@@ -491,6 +491,23 @@ public class CapgoUpdater {
491
491
  }
492
492
  }
493
493
 
494
+ public void cleanupDeltaCache() {
495
+ if (this.activity == null) {
496
+ logger.warn("Activity is null, skipping delta cache cleanup");
497
+ return;
498
+ }
499
+ final File cacheFolder = new File(this.activity.getCacheDir(), "capgo_downloads");
500
+ if (!cacheFolder.exists()) {
501
+ return;
502
+ }
503
+ try {
504
+ this.deleteDirectory(cacheFolder);
505
+ logger.info("Cleaned up delta cache folder");
506
+ } catch (IOException e) {
507
+ logger.error("Failed to cleanup delta cache: " + e.getMessage());
508
+ }
509
+ }
510
+
494
511
  public void cleanupDownloadDirectories(final Set<String> allowedIds) {
495
512
  if (this.documentsDir == null) {
496
513
  logger.warn("Documents directory is null, skipping download cleanup");
@@ -194,6 +194,7 @@ public class CryptoCipher {
194
194
  return checksum;
195
195
  }
196
196
  try {
197
+ // TODO: remove this in a month or two
197
198
  // Determine if input is hex or base64 encoded
198
199
  // Hex strings only contain 0-9 and a-f, while base64 contains other characters
199
200
  byte[] checksumBytes;
@@ -54,7 +54,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
54
54
  CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
55
55
  ]
56
56
  public var implementation = CapgoUpdater()
57
- private let pluginVersion: String = "5.30.0"
57
+ private let pluginVersion: String = "5.31.0"
58
58
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
59
59
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
60
60
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
@@ -366,6 +366,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
366
366
  return id.isEmpty ? nil : id
367
367
  })
368
368
  implementation.cleanupDownloadDirectories(allowedIds: allowedIds)
369
+ implementation.cleanupDeltaCache()
369
370
  }
370
371
  UserDefaults.standard.set(self.currentBuildVersion, forKey: "LatestNativeBuildVersion")
371
372
  UserDefaults.standard.synchronize()
@@ -975,6 +975,19 @@ import UIKit
975
975
  return self.delete(id: id, removeInfo: true)
976
976
  }
977
977
 
978
+ public func cleanupDeltaCache() {
979
+ let fileManager = FileManager.default
980
+ guard fileManager.fileExists(atPath: cacheFolder.path) else {
981
+ return
982
+ }
983
+ do {
984
+ try fileManager.removeItem(at: cacheFolder)
985
+ logger.info("Cleaned up delta cache folder")
986
+ } catch {
987
+ logger.error("Failed to cleanup delta cache: \(error.localizedDescription)")
988
+ }
989
+ }
990
+
978
991
  public func cleanupDownloadDirectories(allowedIds: Set<String>) {
979
992
  let bundleRoot = libraryDir.appendingPathComponent(bundleDirectory)
980
993
  let fileManager = FileManager.default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "5.30.0",
3
+ "version": "5.31.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",