Fix download resume corruption when server returns HTTP 200
When resuming a download after interruption, if the server returns
HTTP 200 (full resource) instead of HTTP 206 (partial content), the
code correctly resets mMission.done but fails to reset the 'start'
variable. This causes the subsequent file seek to use a stale offset,
writing new data at incorrect positions.
This bug causes file corruption for large downloads (>5GB) that are
interrupted and resumed, particularly when:
- Switching between WiFi networks
- Server CDN returning different responses
- Connection drops during long downloads
The corruption manifests as duplicate data regions in the file,
which for MP4 downloads results in multiple MOOV atoms and
broken seek functionality.
Fix: Reset start=0 when HTTP 200 is received, ensuring the file
write position correctly restarts from the beginning of the current
resource.
(cherry picked from commit e451f2924d)
This commit is contained in:
parent
61077c9ad9
commit
f4e140e090
1 changed files with 1 additions and 0 deletions
|
|
@ -85,6 +85,7 @@ public class DownloadRunnableFallback extends Thread {
|
|||
if (mMission.unknownLength || mConn.getResponseCode() == 200) {
|
||||
// restart amount of bytes downloaded
|
||||
mMission.done = mMission.offsets[mMission.current] - mMission.offsets[0];
|
||||
start = 0; // reset position to avoid writing at wrong offset
|
||||
}
|
||||
|
||||
mF = mMission.storage.getStream();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue