diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2013-06-09 18:33:48 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2013-06-09 18:49:55 +0200 |
commit | 2128d3fce44da34ecb1f0d784b703807f66b20f9 (patch) | |
tree | 0daac9f27c6de68ccb0ef662f7541e9426460b83 /apt-pkg | |
parent | 57da1b4bd21aceced30f658993fb811a5232cff7 (diff) |
fail in CopyFile if the FileFds have error flag set
Testing for global PendingErrors in users of CopyFile is incorrect
in so far as unrelated errors will prevent us from copying perfectly
fine files and checking for the validity of the files is just better
in CopyFiles as it already checks if files are at least opened.
Add also a higher-level error message to the error stack if it fails.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 3 | ||||
-rw-r--r-- | apt-pkg/indexcopy.cc | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 7c3a302e2..0f88923cf 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -184,7 +184,8 @@ bool RunScripts(const char *Cnf) /* The caller is expected to set things so that failure causes erasure */ bool CopyFile(FileFd &From,FileFd &To) { - if (From.IsOpen() == false || To.IsOpen() == false) + if (From.IsOpen() == false || To.IsOpen() == false || + From.Failed() == true || To.Failed() == true) return false; // Buffered copy between fds diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 0e36b3ded..1d61b974d 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -544,11 +544,9 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/ FileFd Rel; Target.Open(TargetF,FileFd::WriteAtomic); Rel.Open(prefix + file,FileFd::ReadOnly); - if (_error->PendingError() == true) - return false; if (CopyFile(Rel,Target) == false) - return false; - + return _error->Error("Copying of '%s' for '%s' from '%s' failed", file.c_str(), CDName.c_str(), prefix.c_str()); + return true; } /*}}}*/ |