@capgo/capacitor-updater 6.0.56 → 6.0.59
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 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +3 -3
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +1 -3
- package/package.json +1 -1
|
@@ -339,7 +339,7 @@ public class CapacitorUpdater {
|
|
|
339
339
|
final File downloaded = new File(this.documentsDir, dest);
|
|
340
340
|
this.decryptFile(downloaded, sessionKey, version);
|
|
341
341
|
final String checksum;
|
|
342
|
-
checksum = this.
|
|
342
|
+
checksum = this.calcChecksum(downloaded);
|
|
343
343
|
this.notifyDownload(id, 71);
|
|
344
344
|
final File unzipped = this.unzip(id, downloaded, this.randomString());
|
|
345
345
|
downloaded.delete();
|
|
@@ -483,18 +483,23 @@ public class CapacitorUpdater {
|
|
|
483
483
|
this.editor.commit();
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
private String
|
|
486
|
+
private String calcChecksum(File file) {
|
|
487
487
|
final int BUFFER_SIZE = 1024 * 1024 * 5; // 5 MB buffer size
|
|
488
488
|
CRC32 crc = new CRC32();
|
|
489
|
+
|
|
489
490
|
try (FileInputStream fis = new FileInputStream(file)) {
|
|
490
491
|
byte[] buffer = new byte[BUFFER_SIZE];
|
|
491
492
|
int length;
|
|
492
493
|
while ((length = fis.read(buffer)) != -1) {
|
|
493
494
|
crc.update(buffer, 0, length);
|
|
494
495
|
}
|
|
496
|
+
return String.format("%08x", crc.getValue());
|
|
497
|
+
} catch (IOException e) {
|
|
498
|
+
System.err.println(
|
|
499
|
+
TAG + " Cannot calc checksum: " + file.getPath() + " " + e.getMessage()
|
|
500
|
+
);
|
|
501
|
+
return "";
|
|
495
502
|
}
|
|
496
|
-
String enc = String.format("%08X", crc.getValue());
|
|
497
|
-
return enc.toLowerCase();
|
|
498
503
|
}
|
|
499
504
|
|
|
500
505
|
private void decryptFile(
|
|
@@ -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.59";
|
|
59
59
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
60
60
|
|
|
61
61
|
private SharedPreferences.Editor editor;
|
|
@@ -335,7 +335,7 @@ extension CustomError: LocalizedError {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
private func
|
|
338
|
+
private func calcChecksum(filePath: URL) -> String {
|
|
339
339
|
let bufferSize = 1024 * 1024 * 5 // 5 MB
|
|
340
340
|
var checksum = uLong(0)
|
|
341
341
|
|
|
@@ -359,7 +359,7 @@ extension CustomError: LocalizedError {
|
|
|
359
359
|
|
|
360
360
|
return String(format: "%08X", checksum).lowercased()
|
|
361
361
|
} catch {
|
|
362
|
-
print("\(self.TAG) Cannot
|
|
362
|
+
print("\(self.TAG) Cannot calc checksum: \(filePath.path)", error)
|
|
363
363
|
return ""
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -581,7 +581,7 @@ extension CustomError: LocalizedError {
|
|
|
581
581
|
self.notifyDownload(id, 71)
|
|
582
582
|
do {
|
|
583
583
|
try self.decryptFile(filePath: fileURL, sessionKey: sessionKey, version: version)
|
|
584
|
-
checksum = self.
|
|
584
|
+
checksum = self.calcChecksum(filePath: fileURL)
|
|
585
585
|
try self.saveDownloaded(sourceZip: fileURL, id: id, base: self.libraryDir.appendingPathComponent(self.bundleDirectory), notify: true)
|
|
586
586
|
try self.deleteFolder(source: fileURL)
|
|
587
587
|
self.notifyDownload(id, 100)
|
|
@@ -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.59"
|
|
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"
|
|
@@ -127,14 +127,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
private func semaphoreUp() {
|
|
130
|
-
print("\(self.implementation.TAG) semaphoreUp")
|
|
131
130
|
DispatchQueue.global().async {
|
|
132
131
|
self.semaphoreWait(waitTime: 0)
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
private func semaphoreDown() {
|
|
137
|
-
print("\(self.implementation.TAG) semaphoreDown")
|
|
138
136
|
semaphoreReady.signal()
|
|
139
137
|
}
|
|
140
138
|
|