facebook / facebook/fresco

Resume download from point which it was interrupt

Open
#996 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
17.2k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

## Idea

In places with unstable Internet connection with bad internet, there may be a useful feature to be able to download media just from the same position where it was previously interrupted. It is supported by http from at least v1.1 (by "Range" header), but now default fetcher will throw any data it has downloaded if error occurs
## Solution

Put artificially downloaded data in some cache (possible file cache) to be able to resume download. For this purposes (to save flexibility) I propose to use special fetcher which will have it`s internal cache and if cache is hit will firstly give bytes from cache only after that from internet. While downloading media from internet it bytes will be appended just at the end of file in cache.

I have already wrote some code in my fork - just prototype with test app, poorly covered with test and non absolutely reliably - so it will be improved
## Problems

As I am not a very skillful programmer, so I ca not answer some questions which I faced during this job:
1. What is necessary and sufficient condition to say that destination host support offsets (by range header) in bytes and have accepted request with range header (response code 206)?
2. What is necessary and sufficient condition to say that file we are downloading is the same as we downloaded previous from same URI? There are a lot of different headers in http and I am little bit get confused by them...
3. In CONTRIBUTING.md mentioned about unit tests - what is the amount and quality of the tests you demand?

P.S. It will be brilliant if anybody from community or from facebook team will give me some advises)

**UPD**: [Here](https://github.com/facebook/fresco/compare/master...SKART1:master) is the link to actual cross repository compare

Contributor guide

Open the contributing guide

Research direction

Start with CONTRIBUTING.md and the default fetcher described in the issue. Review the linked fork prototype, then investigate HTTP Range requests, response code 206, cache identity, and the needed test coverage. Done means interrupted media downloads can resume safely from cached bytes without mixing different resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.