@capgo/capacitor-updater 8.51.14 → 8.51.15
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/Package.swift +2 -1
- package/README.md +1 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +37 -16
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +46 -23
- package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +23 -7
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +57 -31
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +103 -3
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.d.ts +4 -1
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +6 -5
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +37 -5
- package/package.json +1 -1
|
@@ -781,7 +781,7 @@ import UIKit
|
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
-
private func extractZipEntry(_ archive: Archive, entry: Entry, to destPath: URL) throws {
|
|
784
|
+
private func extractZipEntry(_ archive: Archive, entry: Entry, to destPath: URL, bufferSize: Int = CryptoCipher.ioBufferBytes()) throws {
|
|
785
785
|
let fileManager = FileManager.default
|
|
786
786
|
|
|
787
787
|
switch entry.type {
|
|
@@ -804,14 +804,14 @@ import UIKit
|
|
|
804
804
|
fileHandle.closeFile()
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
-
_ = try archive.extract(entry, bufferSize:
|
|
807
|
+
_ = try archive.extract(entry, bufferSize: bufferSize, skipCRC32: true) { data in
|
|
808
808
|
if !data.isEmpty {
|
|
809
809
|
fileHandle.write(data)
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
case .symlink:
|
|
813
813
|
var linkData = Data()
|
|
814
|
-
_ = try archive.extract(entry, bufferSize:
|
|
814
|
+
_ = try archive.extract(entry, bufferSize: bufferSize, skipCRC32: true) { data in
|
|
815
815
|
linkData.append(data)
|
|
816
816
|
}
|
|
817
817
|
|
|
@@ -840,7 +840,7 @@ import UIKit
|
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
-
|
|
843
|
+
func saveDownloaded(sourceZip: URL, id: String, base: URL, notify: Bool, bufferSize: Int = CryptoCipher.ioBufferBytes()) throws {
|
|
844
844
|
try prepareFolder(source: base)
|
|
845
845
|
let destPersist: URL = base.appendingPathComponent(id)
|
|
846
846
|
let destUnZip: URL = libraryDir.appendingPathComponent(TEMP_UNZIP_PREFIX + randomString(length: 10))
|
|
@@ -887,7 +887,7 @@ import UIKit
|
|
|
887
887
|
try FileManager.default.createDirectory(at: parentDir, withIntermediateDirectories: true, attributes: nil)
|
|
888
888
|
}
|
|
889
889
|
|
|
890
|
-
try self.extractZipEntry(archive, entry: entry, to: destPath)
|
|
890
|
+
try self.extractZipEntry(archive, entry: entry, to: destPath, bufferSize: bufferSize)
|
|
891
891
|
|
|
892
892
|
// Update progress
|
|
893
893
|
processedEntries += 1
|
|
@@ -1736,6 +1736,38 @@ import UIKit
|
|
|
1736
1736
|
try fileManager.copyItem(at: source, to: destination)
|
|
1737
1737
|
}
|
|
1738
1738
|
|
|
1739
|
+
func copyMatchingBuiltinFilesForTests(files: [(source: URL, dest: URL, hash: String)]) throws {
|
|
1740
|
+
let queue = OperationQueue()
|
|
1741
|
+
queue.maxConcurrentOperationCount = CapgoUpdater.manifestMaxConcurrentFiles
|
|
1742
|
+
let lock = NSLock()
|
|
1743
|
+
var firstError: Error?
|
|
1744
|
+
for file in files {
|
|
1745
|
+
queue.addOperation { [weak self] in
|
|
1746
|
+
guard let self else { return }
|
|
1747
|
+
do {
|
|
1748
|
+
guard self.verifyChecksum(file: file.source, expectedHash: file.hash) else {
|
|
1749
|
+
throw NSError(
|
|
1750
|
+
domain: "CapgoInstallPerf",
|
|
1751
|
+
code: 1,
|
|
1752
|
+
userInfo: [NSLocalizedDescriptionKey: "builtin checksum mismatch"]
|
|
1753
|
+
)
|
|
1754
|
+
}
|
|
1755
|
+
try self.copyItemReplacing(from: file.source, to: file.dest)
|
|
1756
|
+
} catch {
|
|
1757
|
+
lock.lock()
|
|
1758
|
+
if firstError == nil {
|
|
1759
|
+
firstError = error
|
|
1760
|
+
}
|
|
1761
|
+
lock.unlock()
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
queue.waitUntilAllOperationsAreFinished()
|
|
1766
|
+
if let firstError {
|
|
1767
|
+
throw firstError
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1739
1771
|
/// Copy via a unique temp name then rename, so a crash cannot leave a
|
|
1740
1772
|
/// non-empty partial file that `isReusableCacheFile` would trust.
|
|
1741
1773
|
private func copyItemAtomically(from source: URL, to destination: URL) throws {
|