@capgo/capacitor-updater 6.0.1 → 6.0.3
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 = "6.0.
|
|
58
|
+
private final String PLUGIN_VERSION = "6.0.3";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -222,6 +222,7 @@ extension CustomError: LocalizedError {
|
|
|
222
222
|
private let versionOs = UIDevice.current.systemVersion
|
|
223
223
|
private let documentsDir: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
|
224
224
|
private let libraryDir: URL = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
|
|
225
|
+
private let bundleDirectoryHot: String = "versions"
|
|
225
226
|
private let DEFAULT_FOLDER: String = ""
|
|
226
227
|
private let bundleDirectory: String = "NoCloud/ionic_built_snapshots"
|
|
227
228
|
private let INFO_SUFFIX: String = "_info"
|
|
@@ -295,7 +296,8 @@ extension CustomError: LocalizedError {
|
|
|
295
296
|
return false
|
|
296
297
|
#endif
|
|
297
298
|
}
|
|
298
|
-
//
|
|
299
|
+
// Persistent path /var/mobile/Containers/Data/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/Library/NoCloud/ionic_built_snapshots/FOLDER
|
|
300
|
+
// Hot Reload path /var/mobile/Containers/Data/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/Documents/FOLDER
|
|
299
301
|
// Normal /private/var/containers/Bundle/Application/8C0C07BE-0FD3-4FD4-B7DF-90A88E12B8C3/App.app/public
|
|
300
302
|
|
|
301
303
|
private func prepareFolder(source: URL) throws {
|
|
@@ -582,7 +584,8 @@ extension CustomError: LocalizedError {
|
|
|
582
584
|
do {
|
|
583
585
|
try self.decryptFile(filePath: fileURL, sessionKey: sessionKey, version: version)
|
|
584
586
|
checksum = self.getChecksum(filePath: fileURL)
|
|
585
|
-
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.
|
|
587
|
+
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.documentsDir.appendingPathComponent(self.bundleDirectoryHot), notify: true)
|
|
588
|
+
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory), notify: false)
|
|
586
589
|
try self.deleteFolder(source: fileURL)
|
|
587
590
|
self.notifyDownload(id, 100)
|
|
588
591
|
} catch {
|
|
@@ -626,7 +629,7 @@ extension CustomError: LocalizedError {
|
|
|
626
629
|
}
|
|
627
630
|
|
|
628
631
|
public func list() -> [BundleInfo] {
|
|
629
|
-
let dest: URL = documentsDir.appendingPathComponent(
|
|
632
|
+
let dest: URL = documentsDir.appendingPathComponent(bundleDirectoryHot)
|
|
630
633
|
do {
|
|
631
634
|
let files: [String] = try FileManager.default.contentsOfDirectory(atPath: dest.path)
|
|
632
635
|
var res: [BundleInfo] = []
|
|
@@ -649,11 +652,17 @@ extension CustomError: LocalizedError {
|
|
|
649
652
|
print("\(self.TAG) Cannot delete \(id)")
|
|
650
653
|
return false
|
|
651
654
|
}
|
|
652
|
-
let destHot: URL =
|
|
655
|
+
let destHot: URL = documentsDir.appendingPathComponent(bundleDirectoryHot).appendingPathComponent(id)
|
|
656
|
+
let destPersist: URL = libraryDir.appendingPathComponent(bundleDirectory).appendingPathComponent(id)
|
|
653
657
|
do {
|
|
654
658
|
try FileManager.default.removeItem(atPath: destHot.path)
|
|
655
659
|
} catch {
|
|
656
|
-
print("\(self.TAG) Folder \(destHot.path), not removed.")
|
|
660
|
+
print("\(self.TAG) Hot Folder \(destHot.path), not removed.")
|
|
661
|
+
}
|
|
662
|
+
do {
|
|
663
|
+
try FileManager.default.removeItem(atPath: destPersist.path)
|
|
664
|
+
} catch {
|
|
665
|
+
print("\(self.TAG) Folder \(destPersist.path), not removed.")
|
|
657
666
|
return false
|
|
658
667
|
}
|
|
659
668
|
if removeInfo {
|
|
@@ -670,6 +679,10 @@ extension CustomError: LocalizedError {
|
|
|
670
679
|
return self.delete(id: id, removeInfo: true)
|
|
671
680
|
}
|
|
672
681
|
|
|
682
|
+
public func getPathHot(id: String) -> URL {
|
|
683
|
+
return documentsDir.appendingPathComponent(self.bundleDirectoryHot).appendingPathComponent(id)
|
|
684
|
+
}
|
|
685
|
+
|
|
673
686
|
public func getBundleDirectory(id: String) -> URL {
|
|
674
687
|
return libraryDir.appendingPathComponent(self.bundleDirectory).appendingPathComponent(id)
|
|
675
688
|
}
|
|
@@ -679,14 +692,18 @@ extension CustomError: LocalizedError {
|
|
|
679
692
|
}
|
|
680
693
|
|
|
681
694
|
private func bundleExists(id: String) -> Bool {
|
|
682
|
-
let destHot: URL = self.
|
|
695
|
+
let destHot: URL = self.getPathHot(id: id)
|
|
696
|
+
let destHotPersist: URL = self.getBundleDirectory(id: id)
|
|
683
697
|
let indexHot: URL = destHot.appendingPathComponent("index.html")
|
|
698
|
+
let indexPersist: URL = destHotPersist.appendingPathComponent("index.html")
|
|
684
699
|
let bundleIndo: BundleInfo = self.getBundleInfo(id: id)
|
|
685
700
|
if
|
|
686
701
|
destHot.exist &&
|
|
687
702
|
destHot.isDirectory &&
|
|
688
|
-
|
|
703
|
+
destHotPersist.exist &&
|
|
704
|
+
destHotPersist.isDirectory &&
|
|
689
705
|
indexHot.exist &&
|
|
706
|
+
indexPersist.exist &&
|
|
690
707
|
!bundleIndo.isDeleted() {
|
|
691
708
|
return true
|
|
692
709
|
}
|
|
@@ -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 = "6.0.
|
|
18
|
+
private let PLUGIN_VERSION: String = "6.0.3"
|
|
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"
|
|
@@ -247,7 +247,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
247
247
|
if BundleInfo.ID_BUILTIN == id {
|
|
248
248
|
dest = Bundle.main.resourceURL!.appendingPathComponent("public")
|
|
249
249
|
} else {
|
|
250
|
-
dest = self.implementation.
|
|
250
|
+
dest = self.implementation.getPathHot(id: id)
|
|
251
251
|
}
|
|
252
252
|
print("\(self.implementation.TAG) Reloading \(id)")
|
|
253
253
|
if let vc = bridge.viewController as? CAPBridgeViewController {
|