|
@@ -867,6 +867,7 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
|
|
|
else
|
|
else
|
|
|
iFd = open(FileName.c_str(), fileflags, Perms);
|
|
iFd = open(FileName.c_str(), fileflags, Perms);
|
|
|
|
|
|
|
|
|
|
+ this->FileName = FileName;
|
|
|
if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false)
|
|
if (iFd == -1 || OpenInternDescriptor(Mode, compressor) == false)
|
|
|
{
|
|
{
|
|
|
if (iFd != -1)
|
|
if (iFd != -1)
|
|
@@ -877,7 +878,6 @@ bool FileFd::Open(string FileName,unsigned int const Mode,APT::Configuration::Co
|
|
|
return _error->Errno("open",_("Could not open file %s"), FileName.c_str());
|
|
return _error->Errno("open",_("Could not open file %s"), FileName.c_str());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this->FileName = FileName;
|
|
|
|
|
SetCloseExec(iFd,true);
|
|
SetCloseExec(iFd,true);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -916,13 +916,13 @@ bool FileFd::OpenDescriptor(int Fd, unsigned int const Mode, APT::Configuration:
|
|
|
d->openmode = Mode;
|
|
d->openmode = Mode;
|
|
|
Flags = (AutoClose) ? FileFd::AutoClose : 0;
|
|
Flags = (AutoClose) ? FileFd::AutoClose : 0;
|
|
|
iFd = Fd;
|
|
iFd = Fd;
|
|
|
|
|
+ this->FileName = "";
|
|
|
if (OpenInternDescriptor(Mode, compressor) == false)
|
|
if (OpenInternDescriptor(Mode, compressor) == false)
|
|
|
{
|
|
{
|
|
|
if (AutoClose)
|
|
if (AutoClose)
|
|
|
close (iFd);
|
|
close (iFd);
|
|
|
return _error->Errno("gzdopen",_("Could not open file descriptor %d"), Fd);
|
|
return _error->Errno("gzdopen",_("Could not open file descriptor %d"), Fd);
|
|
|
}
|
|
}
|
|
|
- this->FileName = "";
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor)
|
|
bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor)
|
|
@@ -1057,11 +1057,21 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
|
|
|
else
|
|
else
|
|
|
#endif
|
|
#endif
|
|
|
Res = read(iFd,To,Size);
|
|
Res = read(iFd,To,Size);
|
|
|
- if (Res < 0 && errno == EINTR)
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+
|
|
|
if (Res < 0)
|
|
if (Res < 0)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (errno == EINTR)
|
|
|
|
|
+ continue;
|
|
|
Flags |= Fail;
|
|
Flags |= Fail;
|
|
|
|
|
+#if APT_USE_ZLIB
|
|
|
|
|
+ if (d->gz != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ int err;
|
|
|
|
|
+ char const * const errmsg = gzerror(d->gz, &err);
|
|
|
|
|
+ if (err != Z_ERRNO)
|
|
|
|
|
+ return _error->Error("gzread: %s (%d: %s)", _("Read error"), err, errmsg);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
return _error->Errno("read",_("Read error"));
|
|
return _error->Errno("read",_("Read error"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1405,7 +1415,7 @@ bool FileFd::Close()
|
|
|
#if APT_USE_ZLIB
|
|
#if APT_USE_ZLIB
|
|
|
if (d != NULL && d->gz != NULL) {
|
|
if (d != NULL && d->gz != NULL) {
|
|
|
int const e = gzclose(d->gz);
|
|
int const e = gzclose(d->gz);
|
|
|
- // gzdopen() on empty files always fails with "buffer error" here, ignore that
|
|
|
|
|
|
|
+ // gzdclose() on empty files always fails with "buffer error" here, ignore that
|
|
|
if (e != 0 && e != Z_BUF_ERROR)
|
|
if (e != 0 && e != Z_BUF_ERROR)
|
|
|
Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
|
|
Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
|
|
|
} else
|
|
} else
|