Skip to content

Commit 08008ca

Browse files
committed
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.
1 parent 25ea75f commit 08008ca

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

app/src/main/java/us/shandian/giga/get/DownloadRunnableFallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public void run() {
8585
if (mMission.unknownLength || mConn.getResponseCode() == 200) {
8686
// restart amount of bytes downloaded
8787
mMission.done = mMission.offsets[mMission.current] - mMission.offsets[0];
88+
start = 0; // reset position to avoid writing at wrong offset
8889
}
8990

9091
mF = mMission.storage.getStream();

0 commit comments

Comments
 (0)