kevva/download — pull request #26 by asahaf (2014-08-25 20:19:54+00:00)
Title: Add the ability to accelerate the download by dividing the file into seg...

## Add the ability to accelerate the download by dividing the file into segments and run concurrent connections and laying the bases to provide resumable file download.

### Add more options:
1. minSegmentSize: **number** (default **265 KB**, segment size in bytes)
2. maxConnectionsCount: **number** (default **4**, number of concurrent connection)
3. fileExistAction: **rename** | **overwrite** | **skip** (default **overwrite**)
4. accelerate: **true** | **false** (default **true**, download by concurrent connections)

* Fixing the issue when downloading large files, since they get downloaded to the memory. The files new are downloaded to the disk directly. When no destination is provided, the default OS temp folder is used.

* Since the file is downloaded by segments, this will lay out the bases to provide resumable file download. The feature is not implemented yet.

* The files list now contains, objects that have url and location (file path in the disk)

The work it works now is each get(url) will create a downloadJob object, this object control all download job operations.

When download.start() is called DownloadJob object, get the metadata of the file (size and type), then preallocate the file space on the disk. When the file space is allocated, the first segment is created with a length of the size of the file. After the the segment is created, the object create a download worker (a worker per segment), the worker job is to handle the download operation for that segment and write the data on the disk in it's proper location (offset) base on the segment length and offset.

Once the first worker starts downloading, the download job object create another segment by splitting the profusely created segment (segment 1) into half (worker 1 keeps operating on segment 1, only the the segment length is changed by splitting. when the worker reach the end of the segment it stops even if the response stream is not ended), and start new worker on the newly created segment and so on.

### Known issues:
1. Since the file is downloaded in segments, this confuses download status because it will show progress bar for each segment