Skip to content

Commit

Permalink
Merge pull request #489 from Cap-go/fix_fake_race_confition
Browse files Browse the repository at this point in the history
fix: fix cleanupObsoleteVersions deleting versions used by capacitor
  • Loading branch information
riderx authored Nov 25, 2024
2 parents 0446e64 + 60989ef commit 72dc84a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class CapacitorUpdaterPlugin extends Plugin {

private static final String updateUrlDefault =
"https://plugin.capgo.app/updates";
private static final String statsUrlDefault = "https://plugin.capgo.app/stats";
private static final String statsUrlDefault =
"https://plugin.capgo.app/stats";
private static final String channelUrlDefault =
"https://plugin.capgo.app/channel_self";

Expand Down Expand Up @@ -223,9 +224,8 @@ public void notifyListeners(final String id, final JSObject res) {
this.updateUrl = this.getConfig().getString("updateUrl", updateUrlDefault);
this.autoUpdate = this.getConfig().getBoolean("autoUpdate", true);
this.appReadyTimeout = this.getConfig().getInt("appReadyTimeout", 10000);
this.implementation.timeout = this.getConfig()
.getInt("responseTimeout", 20) *
1000;
this.implementation.timeout =
this.getConfig().getInt("responseTimeout", 20) * 1000;
boolean resetWhenUpdate =
this.getConfig().getBoolean("resetWhenUpdate", true);

Expand Down
Binary file modified bun.lockb
Binary file not shown.
8 changes: 5 additions & 3 deletions ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
implementation.defaultChannel = getConfig().getString("defaultChannel", "")!
self.implementation.autoReset()

if resetWhenUpdate {
self.cleanupObsoleteVersions()
}

// Load the server
// This is very much swift specific, android does not do that
// In android we depend on the serverBasePath capacitor property
Expand All @@ -132,9 +136,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
if !self.initialLoad() {
print("\(self.implementation.TAG) unable to force reload, the plugin might fallback to the builtin version")
}
if resetWhenUpdate {
self.cleanupObsoleteVersions()
}

let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
nc.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
Expand Down

0 comments on commit 72dc84a

Please sign in to comment.