changx / google-toolbox-for-mac

Automatically exported from code.google.com/p/google-toolbox-for-mac
Apache License 2.0
0 stars 0 forks source link

Broken download resuming support #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
GTM does not support resuming from broken download.

We use the following steps to resume from broken download:
1.Set Range header for request
2.set NSFileHandle of an existed temp file for GTMHttpFetcher
3.let GTMHttpFetcher download data directly into the NSFileHandle

But in GTMHttpFetcher.m:

- (void)connection:(NSURLConnection *)connection 
didReceiveResponse:(NSURLResponse *)response {
  @synchronized(self) {
    // This method is called when the server has determined that it
    // has enough information to create the NSURLResponse
    // it can be called multiple times, for example in the case of a
    // redirect, so each time we reset the data.
    [downloadedData_ setLength:0];

    //=======comment by yuleiming2009==========
    //[downloadFileHandle_ truncateFileAtOffset:0];

    downloadedLength_ = 0;

    [self setResponse:response];

    // Save cookies from the response
    [self handleCookiesForResponse:response];
  }
}

----------------------------
you can see that [downloadFileHandle_ truncateFileAtOffset:0]; is called which 
makes resuming from broken download impossible.

Original issue reported on code.google.com by yuleimin...@gmail.com on 13 Aug 2013 at 5:58

GoogleCodeExporter commented 9 years ago
Please file issues with the fetcher on its issue tracker: 
https://code.google.com/p/gtm-http-fetcher/issues/list

Original comment by thoma...@gmail.com on 14 Nov 2013 at 4:42