diff --git a/app/src/main/java/com/bitchat/android/util/UniversalApkManager.kt b/app/src/main/java/com/bitchat/android/util/UniversalApkManager.kt index 26f9fcce..c4aca052 100644 --- a/app/src/main/java/com/bitchat/android/util/UniversalApkManager.kt +++ b/app/src/main/java/com/bitchat/android/util/UniversalApkManager.kt @@ -219,9 +219,6 @@ class UniversalApkManager(private val context: Context) { Log.d(TAG, "Downloading from: $url") Log.d(TAG, "Expected size: ${expectedSize / 1024 / 1024}MB") - // Check available disk space before downloading - checkDiskSpace(expectedSize) - val tempFile = File(cacheDir, "download_temp.apk") // Check for resumable download @@ -241,6 +238,11 @@ class UniversalApkManager(private val context: Context) { } } + // Bytes already in the temp file have already consumed storage, so + // a resume only needs room for the remaining tail. Promotion is a + // rename and needs no extra space. + checkDiskSpace((expectedSize - existingBytes).coerceAtLeast(0)) + // A temp file that already holds the full asset means the process // died between download and verification. Requesting // "Range: bytes=-" for it would get HTTP 416 forever, so skip