Skip to content

Commit 19e1680

Browse files
committed
live-update: drop progress-scope changes from Brotli PR
1 parent 497de35 commit 19e1680

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

.changeset/odd-pianos-tap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@capawesome/capacitor-live-update": patch
33
---
44

5-
fix(live-update): add Brotli download support on Android and normalize zip progress updates when the total size is unknown
5+
fix(live-update): add Brotli download support on Android

packages/live-update/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,6 @@ private void downloadBundleOfTypeZip(
947947
@Override
948948
public void success() {
949949
try {
950-
if (file.exists()) {
951-
long fileSize = file.length();
952-
DownloadBundleProgressEvent event = new DownloadBundleProgressEvent(bundleId, fileSize, fileSize);
953-
notifyDownloadBundleProgressListeners(event);
954-
}
955950
// Add the bundle
956951
addBundleOfTypeZip(bundleId, file);
957952
// Delete the temporary file

packages/live-update/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class DownloadBundleProgressEvent implements Result {
1616
public DownloadBundleProgressEvent(@NonNull String bundleId, long downloadedBytes, long totalBytes) {
1717
this.bundleId = bundleId;
1818
this.downloadedBytes = downloadedBytes;
19-
this.totalBytes = Math.max(totalBytes, 0);
20-
this.progress = this.totalBytes > 0 ? (double) downloadedBytes / (double) this.totalBytes : 0;
19+
this.totalBytes = totalBytes;
20+
this.progress = (double) downloadedBytes / (double) totalBytes;
2121
}
2222

2323
@NonNull

packages/live-update/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Capacitor
1010
init(bundleId: String, downloadedBytes: Int64, totalBytes: Int64) {
1111
self.bundleId = bundleId
1212
self.downloadedBytes = downloadedBytes
13-
self.totalBytes = max(totalBytes, 0)
14-
self.progress = self.totalBytes > 0 ? Double(downloadedBytes) / Double(self.totalBytes) : 0
13+
self.progress = Double(downloadedBytes) / Double(totalBytes)
14+
self.totalBytes = totalBytes
1515
}
1616

1717
public func toJSObject() -> AnyObject {

packages/live-update/ios/Plugin/LiveUpdate.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,6 @@ import CommonCrypto
575575
let event = DownloadBundleProgressEvent(bundleId: bundleId, downloadedBytes: progress.completedUnitCount, totalBytes: progress.totalUnitCount)
576576
self.notifyDownloadBundleProgressListeners(event)
577577
})
578-
if let attributes = try? FileManager.default.attributesOfItem(atPath: temporaryZipFileUrl.path),
579-
let fileSize = (attributes[.size] as? NSNumber)?.int64Value {
580-
let event = DownloadBundleProgressEvent(bundleId: bundleId, downloadedBytes: fileSize, totalBytes: fileSize)
581-
self.notifyDownloadBundleProgressListeners(event)
582-
}
583578
// Add the bundle
584579
try await addBundleOfTypeZip(bundleId: bundleId, zipFile: temporaryZipFileUrl)
585580
}

0 commit comments

Comments
 (0)