summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-12-16 00:04:52 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-12-16 00:04:52 +0100
commit6fd947bd48449652edf783cfb1362391e63f9be1 (patch)
treed238cb757ec01ef00b1ea2ebc888173d095eb48a /apt-pkg/contrib
parent561f860a385087ea4d863f01cb5e0e050a5e360f (diff)
try seeking on fds opened with OpenDescriptor before giving up
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 44486905f..a98c2cb85 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1154,12 +1154,19 @@ bool FileFd::Seek(unsigned long long To)
if ((d->openmode & ReadOnly) != ReadOnly)
return _error->Error("Reopen is only implemented for read-only files!");
close(iFd);
+ iFd = 0;
if (TemporaryFileName.empty() == false)
iFd = open(TemporaryFileName.c_str(), O_RDONLY);
else if (FileName.empty() == false)
iFd = open(FileName.c_str(), O_RDONLY);
else
- return _error->Error("Reopen is not implemented for OpenDescriptor()-FileFd!");
+ {
+ if (d->compressed_fd > 0)
+ if (lseek(d->compressed_fd, 0, SEEK_SET) != 0)
+ iFd = d->compressed_fd;
+ if (iFd <= 0)
+ return _error->Error("Reopen is not implemented for pipes opened with FileFd::OpenDescriptor()!");
+ }
if (OpenInternDescriptor(d->openmode, d->compressor) == false)
return _error->Error("Seek on file %s because it couldn't be reopened", FileName.c_str());