@capgo/capacitor-updater 5.7.19 → 5.8.1
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.
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +9 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +14 -4
- package/ios/Plugin/CapacitorUpdater.swift +12 -2
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +8 -7
- package/package.json +1 -1
|
@@ -697,6 +697,15 @@ public class CapacitorUpdater {
|
|
|
697
697
|
return false;
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
+
public void autoReset() {
|
|
701
|
+
String id = this.prefs.getString(WebView.CAP_SERVER_PATH, "");
|
|
702
|
+
final BundleInfo currentBundle = this.getBundleInfo(id);
|
|
703
|
+
if (!currentBundle.isBuiltin() && !this.bundleExists(id)) {
|
|
704
|
+
Log.i(TAG, "Folder at bundle path does not exist. Triggering reset.");
|
|
705
|
+
this.reset();
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
700
709
|
public void reset() {
|
|
701
710
|
this.reset(false);
|
|
702
711
|
}
|
|
@@ -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.
|
|
58
|
+
private final String PLUGIN_VERSION = "5.8.1";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -217,6 +217,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
217
217
|
boolean resetWhenUpdate =
|
|
218
218
|
this.getConfig().getBoolean("resetWhenUpdate", true);
|
|
219
219
|
|
|
220
|
+
this.implementation.autoReset();
|
|
220
221
|
if (resetWhenUpdate) {
|
|
221
222
|
this.cleanupObsoleteVersions();
|
|
222
223
|
}
|
|
@@ -366,7 +367,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
366
367
|
@PluginMethod
|
|
367
368
|
public void setUpdateUrl(final PluginCall call) {
|
|
368
369
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
369
|
-
Log.e(
|
|
370
|
+
Log.e(
|
|
371
|
+
CapacitorUpdater.TAG,
|
|
372
|
+
"setUpdateUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
373
|
+
);
|
|
370
374
|
call.reject("setUpdateUrl not allowed");
|
|
371
375
|
return;
|
|
372
376
|
}
|
|
@@ -383,7 +387,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
383
387
|
@PluginMethod
|
|
384
388
|
public void setStatsUrl(final PluginCall call) {
|
|
385
389
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
386
|
-
Log.e(
|
|
390
|
+
Log.e(
|
|
391
|
+
CapacitorUpdater.TAG,
|
|
392
|
+
"setStatsUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
393
|
+
);
|
|
387
394
|
call.reject("setStatsUrl not allowed");
|
|
388
395
|
return;
|
|
389
396
|
}
|
|
@@ -400,7 +407,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
400
407
|
@PluginMethod
|
|
401
408
|
public void setChannelUrl(final PluginCall call) {
|
|
402
409
|
if (!this.getConfig().getBoolean("allowModifyUrl", false)) {
|
|
403
|
-
Log.e(
|
|
410
|
+
Log.e(
|
|
411
|
+
CapacitorUpdater.TAG,
|
|
412
|
+
"setChannelUrl not allowed set allowModifyUrl in your config to true to allow it"
|
|
413
|
+
);
|
|
404
414
|
call.reject("setChannelUrl not allowed");
|
|
405
415
|
return;
|
|
406
416
|
}
|
|
@@ -726,6 +726,17 @@ extension CustomError: LocalizedError {
|
|
|
726
726
|
return false
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
+
public func autoReset() {
|
|
730
|
+
guard let id: String = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH), !id.isEmpty else {
|
|
731
|
+
return
|
|
732
|
+
}
|
|
733
|
+
let currentBundle: BundleInfo = self.getBundleInfo(id: id)
|
|
734
|
+
if !currentBundle.isBuiltin() && !self.bundleExists(id: id) {
|
|
735
|
+
print("\(self.TAG) Folder at bundle path does not exist. Triggering reset.")
|
|
736
|
+
self.reset()
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
729
740
|
public func reset() {
|
|
730
741
|
self.reset(isInternal: false)
|
|
731
742
|
}
|
|
@@ -1008,8 +1019,7 @@ extension CustomError: LocalizedError {
|
|
|
1008
1019
|
return false
|
|
1009
1020
|
}
|
|
1010
1021
|
let newBundle: BundleInfo = self.getBundleInfo(id: nextId)
|
|
1011
|
-
|
|
1012
|
-
if !newBundle.isBuiltin() && !bundle.exist {
|
|
1022
|
+
if !newBundle.isBuiltin() && !self.bundleExists(id: nextId) {
|
|
1013
1023
|
return false
|
|
1014
1024
|
}
|
|
1015
1025
|
UserDefaults.standard.set(nextId, forKey: self.NEXT_VERSION)
|
|
@@ -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.
|
|
18
|
+
private let PLUGIN_VERSION: String = "5.8.1"
|
|
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"
|
|
@@ -81,6 +81,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
81
81
|
implementation.statsUrl = getConfig().getString("statsUrl", CapacitorUpdaterPlugin.statsUrlDefault)!
|
|
82
82
|
implementation.channelUrl = getConfig().getString("channelUrl", CapacitorUpdaterPlugin.channelUrlDefault)!
|
|
83
83
|
implementation.defaultChannel = getConfig().getString("defaultChannel", "")!
|
|
84
|
+
self.implementation.autoReset()
|
|
84
85
|
if resetWhenUpdate {
|
|
85
86
|
self.cleanupObsoleteVersions()
|
|
86
87
|
}
|
|
@@ -143,9 +144,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
@objc func setUpdateUrl(_ call: CAPPluginCall) {
|
|
146
|
-
if !
|
|
147
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
147
148
|
print("\(self.implementation.TAG) setUpdateUrl called without allowModifyUrl")
|
|
148
|
-
call.reject("setUpdateUrl called without allowModifyUrl")
|
|
149
|
+
call.reject("setUpdateUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
149
150
|
return
|
|
150
151
|
}
|
|
151
152
|
guard let url = call.getString("url") else {
|
|
@@ -158,9 +159,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
@objc func setStatsUrl(_ call: CAPPluginCall) {
|
|
161
|
-
if !
|
|
162
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
162
163
|
print("\(self.implementation.TAG) setStatsUrl called without allowModifyUrl")
|
|
163
|
-
call.reject("setStatsUrl called without allowModifyUrl")
|
|
164
|
+
call.reject("setStatsUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
164
165
|
return
|
|
165
166
|
}
|
|
166
167
|
guard let url = call.getString("url") else {
|
|
@@ -173,9 +174,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
@objc func setChannelUrl(_ call: CAPPluginCall) {
|
|
176
|
-
if !
|
|
177
|
+
if !getConfig().getBoolean("allowModifyUrl", false) {
|
|
177
178
|
print("\(self.implementation.TAG) setChannelUrl called without allowModifyUrl")
|
|
178
|
-
call.reject("setChannelUrl called without allowModifyUrl")
|
|
179
|
+
call.reject("setChannelUrl called without allowModifyUrl set allowModifyUrl in your config to true to allow it")
|
|
179
180
|
return
|
|
180
181
|
}
|
|
181
182
|
guard let url = call.getString("url") else {
|