diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-05 20:20:24 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-05 20:20:24 +0100 |
commit | 570590c0640f71c98893051420517894be8eb6eb (patch) | |
tree | 563eeacf3aa349c1c7366c073cfb99348ab1c6a8 /methods/http.cc | |
parent | b7c7eb099c8d228935f9c3fa0a7c788a4018bfb1 (diff) | |
parent | 5c6ceb4557cb6497dea827d1ec4e2615ccd53e50 (diff) |
merged from debian-experimental2
Diffstat (limited to 'methods/http.cc')
-rw-r--r-- | methods/http.cc | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/methods/http.cc b/methods/http.cc index 0d81c73ed..b8ed43cd2 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -1007,31 +1007,21 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) FailFile.c_str(); // Make sure we dont do a malloc in the signal handler FailFd = File->Fd(); FailTime = Srv->Date; - - // Set the expected size - if (Srv->StartPos >= 0) - { - Res.ResumePoint = Srv->StartPos; - if (ftruncate(File->Fd(),Srv->StartPos) < 0) - _error->Errno("ftruncate", _("Failed to truncate file")); - } - - // Set the start point - lseek(File->Fd(),0,SEEK_END); delete Srv->In.Hash; Srv->In.Hash = new Hashes; - - // Fill the Hash if the file is non-empty (resume) - if (Srv->StartPos > 0) + + // Set the expected size and read file for the hashes + if (Srv->StartPos >= 0) { - lseek(File->Fd(),0,SEEK_SET); - if (Srv->In.Hash->AddFD(File->Fd(),Srv->StartPos) == false) + Res.ResumePoint = Srv->StartPos; + File->Truncate(Srv->StartPos); + + if (Srv->In.Hash->AddFD(*File,Srv->StartPos) == false) { _error->Errno("read",_("Problem hashing file")); return ERROR_NOT_FROM_SERVER; } - lseek(File->Fd(),0,SEEK_END); } SetNonBlock(File->Fd(),true); |