Skip to content

Synchronous uploads + downloads

Luke Champine requested to merge upload into master

Upload and Download now block until finished instead of returning immediately. For Download, this means waiting for the file to be completely transferred, decrypted, and (eventually) rebuilt. For Upload, this just means waiting until the file is available, i.e. ready to be downloaded. Since we are currently using full replication, this means Upload returns as soon as one filePiece is uploaded.

The advantage to making these functions synchronous is that the error handling is simplified. Previously, upload and download errors were completely invisible to the user. Now, they will be reported like any other error. Error handling is tricky for Upload, because it may fail for a combination of different reasons, i.e. hosts rejecting file contracts for different reasons. For now we simply return a generic "no pieces could be uploaded" error. It would be fairly easy to return the most common error though (e.g. "file is too large/small"), which would be much more helpful to the user.

Next step is to implement upload progress, probably modeled after download progress (i.e. adding methods to the File interface and polling it from the UI). Again, though, Upload is tricky because you are uploading to multiple sources. So how do you report a percentage? For now we can get away with using the largest percentage among the file pieces, but eventually we'll need something more sophisticated. Once upload progress is implemented on the backend, it should be added to the frontend. Hopefully we can adopt the existing download bar code to this purpose.

Merge request reports