summaryrefslogtreecommitdiff
path: root/methods/http.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-12-17 23:53:31 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-12-17 23:53:31 +0100
commit109eb1511d0cdfa4af3196105cada30bcbb77bc8 (patch)
treec07319a3ddc9a6484561d1cea918aaecade4a7e9 /methods/http.cc
parent1abbc47c045770476f5f9a57c58989d13290d51b (diff)
try to avoid direct usage of .Fd() if possible and do read()s and co
on the FileFd instead
Diffstat (limited to 'methods/http.cc')
-rw-r--r--methods/http.cc24
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);