summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-05-24 15:59:31 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-05-24 15:59:31 +0200
commit4c86a6348d9916b6404709452affa10e9c776efa (patch)
tree617c85f1b90b484064fbf79740ebaad6a8489705 /apt-pkg
parentf8b830ab5888ef2fc7d83b7a79c72fdcb9388748 (diff)
parentb176de3af77f686a512dec04a98e8fa6ce6af908 (diff)
merged from David
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index c7f78cdfb..119cd1974 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1024,7 +1024,20 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
{
Close();
Flags = (AutoClose) ? FileFd::AutoClose : 0;
- iFd = Fd;
+ if (AutoClose == false && (
+#ifdef HAVE_ZLIB
+ compressor.Name == "gzip" ||
+#endif
+#ifdef HAVE_BZ2
+ compressor.Name == "bzip2" ||
+#endif
+ false))
+ {
+ // Need to duplicate fd here or gzclose for cleanup will close the fd as well
+ iFd = dup(Fd);
+ }
+ else
+ iFd = Fd;
this->FileName = "";
if (OpenInternDescriptor(Mode, compressor) == false)
{
@@ -1183,8 +1196,6 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
close(Pipe[0]);
else
close(Pipe[1]);
- if ((Comp == true || FileName.empty() == true) && d->compressed_fd != -1)
- close(d->compressed_fd);
return true;
}
@@ -1712,7 +1723,7 @@ bool FileFd::Close()
}
}
- if ((Flags & Replace) == Replace && iFd >= 0) {
+ if ((Flags & Replace) == Replace) {
if (rename(TemporaryFileName.c_str(), FileName.c_str()) != 0)
Res &= _error->Errno("rename",_("Problem renaming the file %s to %s"), TemporaryFileName.c_str(), FileName.c_str());