Skip to content

Fix stalling downloads

Christopher Schinnerl requested to merge fix-stalling-downloads into master

BUG FIX

Description of Bug and Fix We compute the Received data of a download by incrementing atomicReceivedData by udc.staticFetchLength / minPieces every time we download a piece. Since both of those values are unsigned integers, the division might cause atomicReceivedData to not add up to udc.staticFetchLength after minPieces are completed. The fix is to set atomicReceivedData to udc.staticFetchLength when the download is done.

The reason why this causes downloads to stall is, that the UI and some parts of siac check if download.Received == FileSize to determine if a download is done instead of using the new field download.Completed. This MR changes that for siac but Sia-UI has to be updated by @eddiewang .

Testing Added I added a repro test called testReceivedFieldEqualsFileSize. It failed before the fix and passes now.

Proof of Fix (ie Screenshot if applicable) testReceivedFieldEqualsFileSize is passing.

Merge request reports