QueueURI(Desc);
}
/*}}}*/
+
+// pkgAcqIndex::ValidateFile - Validate the downloaded file /*{{{*/
+// ---------------------------------------------------------------------
+bool pkgAcqIndex::ValidateFile(const std::string &FileName)
+{
+ // FIXME: this can go away once we only ever download stuff that
+ // has a valid hash and we never do GET based probing
+ // FIXME2: this also leaks debian-isms into the code and should go therefore
+
+ /* Always validate the index file for correctness (all indexes must
+ * have a Package field) (LP: #346386) (Closes: #627642)
+ */
+ FileFd fd(DestFile, FileFd::ReadOnly, FileFd::Extension);
+ // Only test for correctness if the content of the file is not empty
+ // (empty is ok)
+ if (fd.Size() > 0)
+ {
+ pkgTagSection sec;
+ pkgTagFile tag(&fd);
+
+ // all our current indexes have a field 'Package' in each section
+ if (_error->PendingError() == true ||
+ tag.Step(sec) == false ||
+ sec.Exists("Package") == false)
+ return false;
+ }
+ return true;
+}
+ /*}}}*/
// AcqIndex::Done - Finished a fetch /*{{{*/
// ---------------------------------------------------------------------
/* This goes through a number of states.. On the initial fetch the
return;
}
- // FIXME: this can go away once we only ever download stuff that
- // has a valid hash and we never do GET based probing
- //
- /* Always verify the index file for correctness (all indexes must
- * have a Package field) (LP: #346386) (Closes: #627642)
- */
- FileFd fd(DestFile, FileFd::ReadOnly, FileFd::Extension);
- // Only test for correctness if the content of the file is not empty
- // (empty is ok)
- if (fd.Size() > 0)
+ if(!ValidateFile(DestFile))
{
- pkgTagSection sec;
- pkgTagFile tag(&fd);
-
- // all our current indexes have a field 'Package' in each section
- if (_error->PendingError() == true || tag.Step(sec) == false || sec.Exists("Package") == false)
- {
- RenameOnError(InvalidFormat);
- Failed(Message, Cfg);
- return;
- }
+ RenameOnError(InvalidFormat);
+ Failed(Message, Cfg);
+ return;
}
-
+
// FIXME: can we void the "Erase" bool here as its very non-local?
std::string CompressedFile = _config->FindDir("Dir::State::lists") + "partial/";
CompressedFile += URItoFileName(RealURI);
/** \return \b true if this object is being fetched from a trusted source. */
virtual bool IsTrusted() const {return false;};
- // report mirror problems
/** \brief Report mirror problem
*
* This allows reporting mirror failures back to a centralized
*/
void ReportMirrorFailure(std::string FailCode);
-
/** \brief Initialize an item.
*
* Adds the item to the list of items known to the acquire
*/
std::string CompressionExtension;
-
/** \brief Do the changes needed to fetch via AptByHash (if needed) */
void InitByHashIfNeeded(const std::string MetaKey);
/** \brief Schedule file for verification after a IMS hit */
void ReverifyAfterIMS();
+ /** \brief Validate the downloaded index file */
+ bool ValidateFile(const std::string &FileName);
+
public:
// Specialized action members
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+ virtual void Done(std::string Message,unsigned long long Size,
+ HashStringList const &Hashes,
pkgAcquire::MethodConfig *Cnf);
virtual std::string Custom600Headers() const;
virtual std::string DescURI() {return Desc.URI;};