@capgo/capacitor-updater 4.2.3 → 4.2.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.
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +13 -11
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +3 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +71 -77
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +185 -168
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +8 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js +9 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +10 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +10 -4
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/BundleInfo.swift +5 -7
- package/ios/Plugin/BundleStatus.swift +3 -3
- package/ios/Plugin/CapacitorUpdater.swift +82 -82
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +43 -43
- package/ios/Plugin/ObjectPreferences.swift +1 -1
- package/package.json +2 -2
package/dist/esm/web.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
const BUNDLE_BUILTIN = {
|
|
2
|
+
const BUNDLE_BUILTIN = {
|
|
3
|
+
status: 'success',
|
|
4
|
+
version: '',
|
|
5
|
+
downloaded: '1970-01-01T00:00:00.000Z',
|
|
6
|
+
id: 'builtin',
|
|
7
|
+
checksum: '',
|
|
8
|
+
};
|
|
3
9
|
export class CapacitorUpdaterWeb extends WebPlugin {
|
|
4
10
|
async download(options) {
|
|
5
11
|
console.warn('Cannot download version in web', options);
|
|
@@ -46,8 +52,8 @@ export class CapacitorUpdaterWeb extends WebPlugin {
|
|
|
46
52
|
async getLatest() {
|
|
47
53
|
console.warn('Cannot getLatest current bundle in web');
|
|
48
54
|
return {
|
|
49
|
-
version:
|
|
50
|
-
message:
|
|
55
|
+
version: '0.0.0',
|
|
56
|
+
message: 'Cannot getLatest current bundle in web',
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
async notifyAppReady() {
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,cAAc,GAAe,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,cAAc,GAAe;IACjC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,0BAA0B;IACtC,EAAE,EAAE,SAAS;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,KAAK,CAAC,QAAQ,CAAC,OAA0C;QACvD,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAuB;QAC/B,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO;IACT,CAAC;IACD,KAAK,CAAC,WAAW;Q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;IACT,CAAC;IACD,KAAK,CAAC,WAAW;QACf,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -5,10 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var core = require('@capacitor/core');
|
|
6
6
|
|
|
7
7
|
const CapacitorUpdater = core.registerPlugin('CapacitorUpdater', {
|
|
8
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorUpdaterWeb()),
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorUpdaterWeb()),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
const BUNDLE_BUILTIN = {
|
|
11
|
+
const BUNDLE_BUILTIN = {
|
|
12
|
+
status: 'success',
|
|
13
|
+
version: '',
|
|
14
|
+
downloaded: '1970-01-01T00:00:00.000Z',
|
|
15
|
+
id: 'builtin',
|
|
16
|
+
checksum: '',
|
|
17
|
+
};
|
|
12
18
|
class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
13
19
|
async download(options) {
|
|
14
20
|
console.warn('Cannot download version in web', options);
|
|
@@ -55,8 +61,8 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
|
55
61
|
async getLatest() {
|
|
56
62
|
console.warn('Cannot getLatest current bundle in web');
|
|
57
63
|
return {
|
|
58
|
-
version:
|
|
59
|
-
message:
|
|
64
|
+
version: '0.0.0',
|
|
65
|
+
message: 'Cannot getLatest current bundle in web',
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
async notifyAppReady() {
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay in web', options);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACFD,MAAM,cAAc,GAAG;AACvB,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,UAAU,EAAE,0BAA0B;AAC1C,IAAI,EAAE,EAAE,SAAS;AACjB,IAAI,QAAQ,EAAE,EAAE;AAChB,CAAC,CAAC;AACK,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAChE,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AAChE,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,mBAAmB,GAAG;AAChC,QAAQ,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;AAC9D,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClC,KAAK;AACL,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE;AACvB,QAAQ,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;AACjE,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAA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ACvD,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;AACxD,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAClD,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -2,10 +2,16 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const CapacitorUpdater = core.registerPlugin('CapacitorUpdater', {
|
|
5
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorUpdaterWeb()),
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorUpdaterWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
const BUNDLE_BUILTIN = {
|
|
8
|
+
const BUNDLE_BUILTIN = {
|
|
9
|
+
status: 'success',
|
|
10
|
+
version: '',
|
|
11
|
+
downloaded: '1970-01-01T00:00:00.000Z',
|
|
12
|
+
id: 'builtin',
|
|
13
|
+
checksum: '',
|
|
14
|
+
};
|
|
9
15
|
class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
10
16
|
async download(options) {
|
|
11
17
|
console.warn('Cannot download version in web', options);
|
|
@@ -52,8 +58,8 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
52
58
|
async getLatest() {
|
|
53
59
|
console.warn('Cannot getLatest current bundle in web');
|
|
54
60
|
return {
|
|
55
|
-
version:
|
|
56
|
-
message:
|
|
61
|
+
version: '0.0.0',
|
|
62
|
+
message: 'Cannot getLatest current bundle in web',
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
async notifyAppReady() {
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay in web', options);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICFD,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC,CAAC;IACK,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,mBAAmB,GAAG;IAChC,QAAQ,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC9D,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClC,KAAK;IACL,IAAI,MAAM,GAAG,CAAC,OAAO,EAA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Y,OAAO,EAAE,OAAO;IAC5B,YAAY,OAAO,EAAE,wCAAwC;IAC7D,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACvD,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IACxD,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAClD,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
import Foundation
|
|
3
2
|
|
|
4
|
-
|
|
5
3
|
@objc public class BundleInfo: NSObject, Decodable, Encodable {
|
|
6
4
|
public static let ID_BUILTIN: String = "builtin"
|
|
7
5
|
public static let VERSION_UNKNOWN: String = "unknown"
|
|
@@ -12,7 +10,7 @@ import Foundation
|
|
|
12
10
|
private let version: String
|
|
13
11
|
private let checksum: String
|
|
14
12
|
private let status: BundleStatus
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
convenience init(id: String, version: String, status: BundleStatus, downloaded: Date, checksum: String) {
|
|
17
15
|
self.init(id: id, version: version, status: status, downloaded: downloaded.iso8601withFractionalSeconds, checksum: checksum)
|
|
18
16
|
}
|
|
@@ -24,11 +22,11 @@ import Foundation
|
|
|
24
22
|
self.checksum = checksum
|
|
25
23
|
self.status = status
|
|
26
24
|
}
|
|
27
|
-
|
|
25
|
+
|
|
28
26
|
enum CodingKeys: String, CodingKey {
|
|
29
27
|
case downloaded, id, version, status, checksum
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
|
|
32
30
|
public func isBuiltin() -> Bool {
|
|
33
31
|
return BundleInfo.ID_BUILTIN == self.id
|
|
34
32
|
}
|
|
@@ -56,7 +54,7 @@ import Foundation
|
|
|
56
54
|
public func setChecksum(checksum: String) -> BundleInfo {
|
|
57
55
|
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum)
|
|
58
56
|
}
|
|
59
|
-
|
|
57
|
+
|
|
60
58
|
public func setDownloaded(downloaded: Date) -> BundleInfo {
|
|
61
59
|
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum)
|
|
62
60
|
}
|
|
@@ -91,7 +89,7 @@ import Foundation
|
|
|
91
89
|
"version": self.getVersionName(),
|
|
92
90
|
"downloaded": self.getDownloaded(),
|
|
93
91
|
"checksum": self.getChecksum(),
|
|
94
|
-
"status": self.getStatus()
|
|
92
|
+
"status": self.getStatus()
|
|
95
93
|
]
|
|
96
94
|
}
|
|
97
95
|
|
|
@@ -10,7 +10,7 @@ struct LocalizedString: ExpressibleByStringLiteral, Equatable {
|
|
|
10
10
|
init(localized: String) {
|
|
11
11
|
self.v = localized
|
|
12
12
|
}
|
|
13
|
-
init(stringLiteral value:String) {
|
|
13
|
+
init(stringLiteral value: String) {
|
|
14
14
|
self.init(key: value)
|
|
15
15
|
}
|
|
16
16
|
init(extendedGraphemeClusterLiteral value: String) {
|
|
@@ -21,7 +21,7 @@ struct LocalizedString: ExpressibleByStringLiteral, Equatable {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
func ==(lhs:LocalizedString, rhs:LocalizedString) -> Bool {
|
|
24
|
+
func ==(lhs: LocalizedString, rhs: LocalizedString) -> Bool {
|
|
25
25
|
return lhs.v == rhs.v
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ enum BundleStatus: LocalizedString, Decodable, Encodable {
|
|
|
34
34
|
var localizedString: String {
|
|
35
35
|
return self.rawValue.v
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
init?(localizedString: String) {
|
|
39
39
|
self.init(rawValue: LocalizedString(localized: localizedString))
|
|
40
40
|
}
|
|
@@ -30,8 +30,8 @@ public class AppVersion: NSObject {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
extension AppVersion {
|
|
33
|
-
func toDict() -> [String:Any] {
|
|
34
|
-
var dict = [String:Any]()
|
|
33
|
+
func toDict() -> [String: Any] {
|
|
34
|
+
var dict = [String: Any]()
|
|
35
35
|
let otherSelf = Mirror(reflecting: self)
|
|
36
36
|
for child in otherSelf.children {
|
|
37
37
|
if let key = child.label {
|
|
@@ -69,12 +69,12 @@ extension Date {
|
|
|
69
69
|
var iso8601withFractionalSeconds: String { return Formatter.iso8601withFractionalSeconds.string(from: self) }
|
|
70
70
|
}
|
|
71
71
|
extension String {
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
var fileURL: URL {
|
|
74
74
|
return URL(fileURLWithPath: self)
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
var lastPathComponent:String {
|
|
76
|
+
|
|
77
|
+
var lastPathComponent: String {
|
|
78
78
|
get {
|
|
79
79
|
return fileURL.lastPathComponent
|
|
80
80
|
}
|
|
@@ -121,7 +121,7 @@ extension CustomError: LocalizedError {
|
|
|
121
121
|
"The file cannot be unflat",
|
|
122
122
|
comment: "Invalid folder"
|
|
123
123
|
)
|
|
124
|
-
case .unexpected
|
|
124
|
+
case .unexpected:
|
|
125
125
|
return NSLocalizedString(
|
|
126
126
|
"An unexpected error occurred.",
|
|
127
127
|
comment: "Unexpected Error"
|
|
@@ -131,7 +131,7 @@ extension CustomError: LocalizedError {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
@objc public class CapacitorUpdater: NSObject {
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
private let versionName = Bundle.main.versionName ?? ""
|
|
136
136
|
private let versionCode = Bundle.main.versionCode ?? ""
|
|
137
137
|
private let versionOs = ProcessInfo().operatingSystemVersion.getFullVersion()
|
|
@@ -143,31 +143,31 @@ extension CustomError: LocalizedError {
|
|
|
143
143
|
private let INFO_SUFFIX = "_info"
|
|
144
144
|
private let FALLBACK_VERSION = "pastVersion"
|
|
145
145
|
private let NEXT_VERSION = "nextVersion"
|
|
146
|
-
|
|
147
|
-
public let TAG = "✨ Capacitor-updater:"
|
|
146
|
+
|
|
147
|
+
public let TAG = "✨ Capacitor-updater:"
|
|
148
148
|
public let CAP_SERVER_PATH = "serverBasePath"
|
|
149
|
-
public let pluginVersion = "4.2.
|
|
149
|
+
public let pluginVersion = "4.2.4"
|
|
150
150
|
public var statsUrl = ""
|
|
151
151
|
public var appId = ""
|
|
152
152
|
public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
153
|
-
|
|
154
|
-
public var notifyDownload: (String, Int) -> Void = { _,_ in }
|
|
153
|
+
|
|
154
|
+
public var notifyDownload: (String, Int) -> Void = { _, _ in }
|
|
155
155
|
|
|
156
156
|
private func calcTotalPercent(percent: Int, min: Int, max: Int) -> Int {
|
|
157
|
-
return (percent * (max - min)) / 100 + min
|
|
157
|
+
return (percent * (max - min)) / 100 + min
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
private func randomString(length: Int) -> String {
|
|
161
161
|
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
162
|
-
return String((0..<length).map{ _ in letters.randomElement()! })
|
|
162
|
+
return String((0..<length).map { _ in letters.randomElement()! })
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
// Persistent path /var/mobile/Containers/Data/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/Library/NoCloud/ionic_built_snapshots/FOLDER
|
|
166
166
|
// Hot Reload path /var/mobile/Containers/Data/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/Documents/FOLDER
|
|
167
167
|
// Normal /private/var/containers/Bundle/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/App.app/public
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
private func prepareFolder(source: URL) throws {
|
|
170
|
-
if
|
|
170
|
+
if !FileManager.default.fileExists(atPath: source.path) {
|
|
171
171
|
do {
|
|
172
172
|
try FileManager.default.createDirectory(atPath: source.path, withIntermediateDirectories: true, attributes: nil)
|
|
173
173
|
} catch {
|
|
@@ -176,7 +176,7 @@ extension CustomError: LocalizedError {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
private func deleteFolder(source: URL) throws {
|
|
181
181
|
do {
|
|
182
182
|
try FileManager.default.removeItem(atPath: source.path)
|
|
@@ -185,12 +185,12 @@ extension CustomError: LocalizedError {
|
|
|
185
185
|
throw CustomError.cannotDeleteDirectory
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
|
|
189
189
|
private func unflatFolder(source: URL, dest: URL) throws -> Bool {
|
|
190
190
|
let index = source.appendingPathComponent("index.html")
|
|
191
191
|
do {
|
|
192
192
|
let files = try FileManager.default.contentsOfDirectory(atPath: source.path)
|
|
193
|
-
if
|
|
193
|
+
if files.count == 1 && source.appendingPathComponent(files[0]).isDirectory && !FileManager.default.fileExists(atPath: index.path) {
|
|
194
194
|
try FileManager.default.moveItem(at: source.appendingPathComponent(files[0]), to: dest)
|
|
195
195
|
return true
|
|
196
196
|
} else {
|
|
@@ -207,21 +207,21 @@ extension CustomError: LocalizedError {
|
|
|
207
207
|
do {
|
|
208
208
|
let fileData = try Data.init(contentsOf: filePath)
|
|
209
209
|
let checksum = fileData.withUnsafeBytes { crc32(0, $0.bindMemory(to: Bytef.self).baseAddress, uInt(fileData.count)) }
|
|
210
|
-
return String(format:"%08X", checksum).lowercased()
|
|
210
|
+
return String(format: "%08X", checksum).lowercased()
|
|
211
211
|
} catch {
|
|
212
212
|
print("\(self.TAG) Cannot get checksum: \(filePath.path)", error)
|
|
213
213
|
return ""
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
private func saveDownloaded(sourceZip: URL, id: String, base: URL) throws
|
|
216
|
+
|
|
217
|
+
private func saveDownloaded(sourceZip: URL, id: String, base: URL) throws {
|
|
218
218
|
try prepareFolder(source: base)
|
|
219
219
|
let destHot = base.appendingPathComponent(id)
|
|
220
220
|
let destUnZip = documentsDir.appendingPathComponent(randomString(length: 10))
|
|
221
|
-
if
|
|
221
|
+
if !SSZipArchive.unzipFile(atPath: sourceZip.path, toDestination: destUnZip.path) {
|
|
222
222
|
throw CustomError.cannotUnzip
|
|
223
223
|
}
|
|
224
|
-
if
|
|
224
|
+
if try unflatFolder(source: destUnZip, dest: destHot) {
|
|
225
225
|
try deleteFolder(source: destUnZip)
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -240,32 +240,32 @@ extension CustomError: LocalizedError {
|
|
|
240
240
|
"version_name": self.getCurrentBundle().getVersionName()
|
|
241
241
|
]
|
|
242
242
|
print("\(self.TAG) Auto-update parameters: \(parameters)")
|
|
243
|
-
let request = AF.request(url, method: .post,parameters: parameters, encoder: JSONParameterEncoder.default)
|
|
243
|
+
let request = AF.request(url, method: .post, parameters: parameters, encoder: JSONParameterEncoder.default)
|
|
244
244
|
|
|
245
245
|
request.validate().responseDecodable(of: AppVersionDec.self) { response in
|
|
246
246
|
switch response.result {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
247
|
+
case .success:
|
|
248
|
+
if let url = response.value?.url {
|
|
249
|
+
latest.url = url
|
|
250
|
+
}
|
|
251
|
+
if let version = response.value?.version {
|
|
252
|
+
latest.version = version
|
|
253
|
+
}
|
|
254
|
+
if let major = response.value?.major {
|
|
255
|
+
latest.major = major
|
|
256
|
+
}
|
|
257
|
+
if let message = response.value?.message {
|
|
258
|
+
latest.message = message
|
|
259
|
+
}
|
|
260
|
+
case let .failure(error):
|
|
261
|
+
print("\(self.TAG) Error getting Latest", error )
|
|
262
262
|
}
|
|
263
263
|
semaphore.signal()
|
|
264
264
|
}
|
|
265
265
|
semaphore.wait()
|
|
266
266
|
return latest
|
|
267
267
|
}
|
|
268
|
-
|
|
268
|
+
|
|
269
269
|
private func setCurrentBundle(bundle: String) {
|
|
270
270
|
UserDefaults.standard.set(bundle, forKey: self.CAP_SERVER_PATH)
|
|
271
271
|
UserDefaults.standard.synchronize()
|
|
@@ -276,7 +276,7 @@ extension CustomError: LocalizedError {
|
|
|
276
276
|
let semaphore = DispatchSemaphore(value: 0)
|
|
277
277
|
let id: String = self.randomString(length: 10)
|
|
278
278
|
var checksum = ""
|
|
279
|
-
var mainError: NSError?
|
|
279
|
+
var mainError: NSError?
|
|
280
280
|
let destination: DownloadRequest.Destination = { _, _ in
|
|
281
281
|
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
282
282
|
let fileURL = documentsURL.appendingPathComponent(self.randomString(length: 10))
|
|
@@ -284,7 +284,7 @@ extension CustomError: LocalizedError {
|
|
|
284
284
|
return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
|
|
285
285
|
}
|
|
286
286
|
let request = AF.download(url, to: destination)
|
|
287
|
-
|
|
287
|
+
|
|
288
288
|
request.downloadProgress { progress in
|
|
289
289
|
let percent = self.calcTotalPercent(percent: Int(progress.fractionCompleted * 100), min: 10, max: 70)
|
|
290
290
|
self.notifyDownload(id, percent)
|
|
@@ -315,7 +315,7 @@ extension CustomError: LocalizedError {
|
|
|
315
315
|
self.saveBundleInfo(id: id, bundle: BundleInfo(id: id, version: version, status: BundleStatus.DOWNLOADING, downloaded: Date(), checksum: checksum))
|
|
316
316
|
self.notifyDownload(id, 0)
|
|
317
317
|
semaphore.wait()
|
|
318
|
-
if
|
|
318
|
+
if mainError != nil {
|
|
319
319
|
throw mainError!
|
|
320
320
|
}
|
|
321
321
|
let info: BundleInfo = BundleInfo(id: id, version: version, status: BundleStatus.PENDING, downloaded: Date(), checksum: checksum)
|
|
@@ -329,9 +329,9 @@ extension CustomError: LocalizedError {
|
|
|
329
329
|
let files = try FileManager.default.contentsOfDirectory(atPath: dest.path)
|
|
330
330
|
var res: [BundleInfo] = []
|
|
331
331
|
print("\(self.TAG) list File : \(dest.path)")
|
|
332
|
-
if
|
|
332
|
+
if dest.exist {
|
|
333
333
|
for id in files {
|
|
334
|
-
res.append(self.getBundleInfo(id: id))
|
|
334
|
+
res.append(self.getBundleInfo(id: id))
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
return res
|
|
@@ -340,10 +340,10 @@ extension CustomError: LocalizedError {
|
|
|
340
340
|
return []
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
public func delete(id: String, removeInfo: Bool) -> Bool {
|
|
345
345
|
let deleted: BundleInfo = self.getBundleInfo(id: id)
|
|
346
|
-
if
|
|
346
|
+
if deleted.isBuiltin() || self.getCurrentBundleId() == id {
|
|
347
347
|
print("\(self.TAG) Cannot delete \(id)")
|
|
348
348
|
return false
|
|
349
349
|
}
|
|
@@ -360,7 +360,7 @@ extension CustomError: LocalizedError {
|
|
|
360
360
|
print("\(self.TAG) Folder \(destPersist.path), not removed.")
|
|
361
361
|
return false
|
|
362
362
|
}
|
|
363
|
-
if
|
|
363
|
+
if removeInfo {
|
|
364
364
|
self.removeBundleInfo(id: id)
|
|
365
365
|
}
|
|
366
366
|
self.removeBundleInfo(id: id)
|
|
@@ -377,7 +377,7 @@ extension CustomError: LocalizedError {
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
public func set(bundle: BundleInfo) -> Bool {
|
|
380
|
-
return self.set(id: bundle.getId())
|
|
380
|
+
return self.set(id: bundle.getId())
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
private func bundleExists(id: String) -> Bool {
|
|
@@ -386,19 +386,19 @@ extension CustomError: LocalizedError {
|
|
|
386
386
|
let indexHot = destHot.appendingPathComponent("index.html")
|
|
387
387
|
let indexPersist = destHotPersist.appendingPathComponent("index.html")
|
|
388
388
|
let url: URL = self.getBundleDirectory(id: id)
|
|
389
|
-
if
|
|
390
|
-
return true
|
|
389
|
+
if url.isDirectory && destHotPersist.isDirectory && indexHot.exist && indexPersist.exist {
|
|
390
|
+
return true
|
|
391
391
|
}
|
|
392
|
-
return false
|
|
392
|
+
return false
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
public func set(id: String) -> Bool {
|
|
396
396
|
let newBundle: BundleInfo = self.getBundleInfo(id: id)
|
|
397
|
-
if
|
|
397
|
+
if newBundle.isBuiltin() {
|
|
398
398
|
self.reset()
|
|
399
399
|
return true
|
|
400
400
|
}
|
|
401
|
-
if
|
|
401
|
+
if bundleExists(id: id) {
|
|
402
402
|
self.setCurrentBundle(bundle: self.getBundleDirectory(id: id).path)
|
|
403
403
|
self.setBundleStatus(id: id, status: BundleStatus.PENDING)
|
|
404
404
|
sendStats(action: "set", versionName: newBundle.getVersionName())
|
|
@@ -407,37 +407,37 @@ extension CustomError: LocalizedError {
|
|
|
407
407
|
sendStats(action: "set_fail", versionName: newBundle.getVersionName())
|
|
408
408
|
return false
|
|
409
409
|
}
|
|
410
|
-
|
|
410
|
+
|
|
411
411
|
public func getPathHot(id: String) -> URL {
|
|
412
412
|
return documentsDir.appendingPathComponent(self.bundleDirectoryHot).appendingPathComponent(id)
|
|
413
413
|
}
|
|
414
|
-
|
|
414
|
+
|
|
415
415
|
public func getPathPersist(id: String) -> URL {
|
|
416
416
|
return libraryDir.appendingPathComponent(self.bundleDirectory).appendingPathComponent(id)
|
|
417
417
|
}
|
|
418
|
-
|
|
418
|
+
|
|
419
419
|
public func reset() {
|
|
420
420
|
self.reset(isInternal: false)
|
|
421
421
|
}
|
|
422
|
-
|
|
422
|
+
|
|
423
423
|
public func reset(isInternal: Bool) {
|
|
424
424
|
print("\(self.TAG) reset: \(isInternal)")
|
|
425
425
|
self.setCurrentBundle(bundle: "")
|
|
426
426
|
self.setFallbackBundle(fallback: Optional<BundleInfo>.none)
|
|
427
|
-
|
|
428
|
-
if
|
|
427
|
+
_ = self.setNextBundle(next: Optional<String>.none)
|
|
428
|
+
if !isInternal {
|
|
429
429
|
sendStats(action: "reset", versionName: self.getCurrentBundle().getVersionName())
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
|
|
433
433
|
public func setSuccess(bundle: BundleInfo, autoDeletePrevious: Bool) {
|
|
434
434
|
self.setBundleStatus(id: bundle.getId(), status: BundleStatus.SUCCESS)
|
|
435
435
|
let fallback: BundleInfo = self.getFallbackBundle()
|
|
436
436
|
print("\(self.TAG) Fallback bundle is: \(fallback.toString())")
|
|
437
437
|
print("\(self.TAG) Version successfully loaded: \(bundle.toString())")
|
|
438
|
-
if
|
|
438
|
+
if autoDeletePrevious && !fallback.isBuiltin() {
|
|
439
439
|
let res = self.delete(id: fallback.getId())
|
|
440
|
-
if
|
|
440
|
+
if res {
|
|
441
441
|
print("\(self.TAG) Deleted previous bundle: \(fallback.toString())")
|
|
442
442
|
} else {
|
|
443
443
|
print("\(self.TAG) Failed to delete previous bundle: \(fallback.toString())")
|
|
@@ -445,13 +445,13 @@ extension CustomError: LocalizedError {
|
|
|
445
445
|
}
|
|
446
446
|
self.setFallbackBundle(fallback: bundle)
|
|
447
447
|
}
|
|
448
|
-
|
|
448
|
+
|
|
449
449
|
public func setError(bundle: BundleInfo) {
|
|
450
|
-
self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR)
|
|
450
|
+
self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR)
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
func sendStats(action: String, versionName: String) {
|
|
454
|
-
if
|
|
454
|
+
if statsUrl == "" { return }
|
|
455
455
|
let parameters: [String: String] = [
|
|
456
456
|
"platform": "ios",
|
|
457
457
|
"action": action,
|
|
@@ -464,7 +464,7 @@ extension CustomError: LocalizedError {
|
|
|
464
464
|
"app_id": self.appId
|
|
465
465
|
]
|
|
466
466
|
DispatchQueue.global(qos: .background).async {
|
|
467
|
-
let request = AF.request(self.statsUrl, method: .post,parameters: parameters, encoder: JSONParameterEncoder.default)
|
|
467
|
+
let request = AF.request(self.statsUrl, method: .post, parameters: parameters, encoder: JSONParameterEncoder.default)
|
|
468
468
|
request.responseData { response in
|
|
469
469
|
switch response.result {
|
|
470
470
|
case .success:
|
|
@@ -478,14 +478,14 @@ extension CustomError: LocalizedError {
|
|
|
478
478
|
|
|
479
479
|
public func getBundleInfo(id: String?) -> BundleInfo {
|
|
480
480
|
var trueId = BundleInfo.VERSION_UNKNOWN
|
|
481
|
-
if
|
|
481
|
+
if id != nil {
|
|
482
482
|
trueId = id!
|
|
483
483
|
}
|
|
484
484
|
print("\(self.TAG) Getting info for bundle [\(trueId)]")
|
|
485
|
-
let result: BundleInfo
|
|
486
|
-
if
|
|
485
|
+
let result: BundleInfo
|
|
486
|
+
if BundleInfo.ID_BUILTIN == trueId {
|
|
487
487
|
result = BundleInfo(id: trueId, version: "", status: BundleStatus.SUCCESS, checksum: "")
|
|
488
|
-
} else if
|
|
488
|
+
} else if BundleInfo.VERSION_UNKNOWN == trueId {
|
|
489
489
|
result = BundleInfo(id: trueId, version: "", status: BundleStatus.ERROR, checksum: "")
|
|
490
490
|
} else {
|
|
491
491
|
do {
|
|
@@ -496,13 +496,13 @@ extension CustomError: LocalizedError {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
print("\(self.TAG) Returning info bundle [\(result.toString())]")
|
|
499
|
-
return result
|
|
499
|
+
return result
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
public func getBundleInfoByVersionName(version: String) -> BundleInfo? {
|
|
503
|
-
let installed
|
|
503
|
+
let installed: [BundleInfo] = self.list()
|
|
504
504
|
for i in installed {
|
|
505
|
-
if
|
|
505
|
+
if i.getVersionName() == version {
|
|
506
506
|
return i
|
|
507
507
|
}
|
|
508
508
|
}
|
|
@@ -514,11 +514,11 @@ extension CustomError: LocalizedError {
|
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
private func saveBundleInfo(id: String, bundle: BundleInfo?) {
|
|
517
|
-
if
|
|
517
|
+
if bundle != nil && (bundle!.isBuiltin() || bundle!.isUnknown()) {
|
|
518
518
|
print("\(self.TAG) Not saving info for bundle [\(id)]", bundle!.toString())
|
|
519
519
|
return
|
|
520
520
|
}
|
|
521
|
-
if
|
|
521
|
+
if bundle == nil {
|
|
522
522
|
print("\(self.TAG) Removing info for bundle [\(id)]")
|
|
523
523
|
UserDefaults.standard.removeObject(forKey: "\(id)\(self.INFO_SUFFIX)")
|
|
524
524
|
} else {
|
|
@@ -546,14 +546,14 @@ extension CustomError: LocalizedError {
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
public func getCurrentBundle() -> BundleInfo {
|
|
549
|
-
return self.getBundleInfo(id: self.getCurrentBundleId())
|
|
549
|
+
return self.getBundleInfo(id: self.getCurrentBundleId())
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
public func getCurrentBundleId() -> String {
|
|
553
553
|
guard let bundlePath = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) else {
|
|
554
554
|
return BundleInfo.ID_BUILTIN
|
|
555
555
|
}
|
|
556
|
-
if
|
|
556
|
+
if bundlePath == "" {
|
|
557
557
|
return BundleInfo.ID_BUILTIN
|
|
558
558
|
}
|
|
559
559
|
let bundleID = bundlePath.components(separatedBy: "/").last ?? bundlePath
|
|
@@ -587,7 +587,7 @@ extension CustomError: LocalizedError {
|
|
|
587
587
|
}
|
|
588
588
|
let newBundle: BundleInfo = self.getBundleInfo(id: nextId)
|
|
589
589
|
let bundle: URL = self.getBundleDirectory(id: nextId)
|
|
590
|
-
if
|
|
590
|
+
if !newBundle.isBuiltin() && !bundle.exist {
|
|
591
591
|
return false
|
|
592
592
|
}
|
|
593
593
|
UserDefaults.standard.set(nextId, forKey: self.NEXT_VERSION)
|