@onekeyfe/react-native-app-update 6.7.0-alpha.310 → 6.7.0-alpha.324

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.
@@ -97,6 +97,7 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
97
97
  // files "<partial>.seg0".."<partial>.seg${N-1}", and Phase 2 below
98
98
  // scans this range to detect an in-flight concurrent download.
99
99
  private const val CONCURRENT_SEGMENT_COUNT = AppUpdateLogic.CONCURRENT_SEGMENT_COUNT
100
+ private const val MAX_APK_SIZE = 512L * 1024 * 1024
100
101
  }
101
102
 
102
103
  private val listeners = CopyOnWriteArrayList<Listener>()
@@ -759,7 +760,12 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
759
760
  // files to the read-only root fs → EROFS. Resolve it to
760
761
  // the real apks dir (filesDir/apks) first, exactly like
761
762
  // react-native-bundle-update passes an absolute path.
762
- ).download(url, partialFile.absolutePath, cancelHandle) { transferred, total ->
763
+ ).download(
764
+ url,
765
+ partialFile.absolutePath,
766
+ cancelHandle,
767
+ maxTotalBytes = MAX_APK_SIZE,
768
+ ) { transferred, total ->
763
769
  if (cancelHandle.aborted.get()) return@download
764
770
  if (total > 0) {
765
771
  val p = ((transferred * 100) / total).toInt().coerceIn(0, 100)
@@ -951,7 +957,6 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
951
957
  // a resumed download's first event is already >0%).
952
958
  var prevProgress = -1
953
959
 
954
- val maxApkSize = 512L * 1024 * 1024
955
960
  body.byteStream().use { inputStream ->
956
961
  FileOutputStream(partialFile.absolutePath, appendMode).use { outputStream ->
957
962
  val buffer = ByteArray(8192)
@@ -959,7 +964,7 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
959
964
  while (inputStream.read(buffer).also { bytesRead = it } != -1) {
960
965
  ensureNotCancelled()
961
966
  totalBytesRead += bytesRead
962
- if (totalBytesRead > maxApkSize) {
967
+ if (totalBytesRead > MAX_APK_SIZE) {
963
968
  throw AppUpdateError("SECURITY_REJECTED", "download")
964
969
  }
965
970
  outputStream.write(buffer, 0, bytesRead)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-app-update",
3
- "version": "6.7.0-alpha.310",
3
+ "version": "6.7.0-alpha.324",
4
4
  "description": "Android APK download, signature verification and installation for OneKey",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",