* \param To The new name of \a From. If \a To exists it will be
* overwritten.
*/
- void Rename(std::string From,std::string To);
+ bool Rename(std::string From,std::string To);
public:
/** \brief If not \b NULL, contains the name of a subprocess that
* is operating on this object (for instance, "gzip" or "gpgv").
*/
- const char *Mode;
+ APT_DEPRECATED const char *Mode;
+
+ /** \brief contains the name of the subprocess that is operating on this object
+ * (for instance, "gzip", "rred" or "gpgv"). This is obsoleting #Mode from above
+ * as it can manage the lifetime of included string properly. */
+ std::string ActiveSubprocess;
/** \brief A client-supplied unique identifier.
*
*
* \return a URI that should be used to describe what is being fetched.
*/
- virtual std::string DescURI() const = 0;
+ virtual std::string DescURI() = 0;
/** \brief Short item description.
*
* \return a brief description of the object being fetched.
*/
- virtual std::string ShortDesc() const {return DescURI();}
+ virtual std::string ShortDesc() {return DescURI();}
/** \brief Invoked by the worker when the download is completely done. */
virtual void Finished() {};
/** \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
enum RenameOnErrorState {
HashSumMismatch,
SizeMismatch,
- InvalidFormat
+ InvalidFormat,
+ SignatureError,
+ NotClearsigned,
};
/** \brief Rename failed file and set error
protected:
std::vector<Item*> Transaction;
+ /** \brief A package-system-specific parser for the meta-index file. */
+ indexRecords *MetaIndexParser;
+
+ /** \brief The index files which should be looked up in the meta-index
+ * and then downloaded.
+ */
+ const std::vector<IndexTarget*>* IndexTargets;
+
+ /** \brief If \b true, the index's signature is currently being verified.
+ */
+ bool AuthPass;
+
+ // required to deal gracefully with problems caused by incorrect ims hits
+ bool IMSHit;
+
+ /** \brief Starts downloading the individual index files.
+ *
+ * \param verify If \b true, only indices whose expected hashsum
+ * can be determined from the meta-index will be downloaded, and
+ * the hashsums of indices will be checked (reporting
+ * #StatAuthError if there is a mismatch). If verify is \b false,
+ * no hashsum checking will be performed.
+ */
+ void QueueIndexes(bool verify);
+
public:
// transaction code
void Add(Item *I);
bool TransactionHasError() APT_PURE;
void CommitTransaction();
+ /** \brief Stage (queue) a copy action when the transaction is commited
+ */
+ void TransactionStageCopy(Item *I,
+ const std::string &From,
+ const std::string &To);
+ /** \brief Stage (queue) a removal action when the transaction is commited
+ */
+ void TransactionStageRemoval(Item *I, const std::string &FinalFile);
+
// helper for the signature warning
bool GenerateAuthWarning(const std::string &RealURI,
const std::string &Message);
pkgAcqMetaBase(pkgAcquire *Owner,
+ const std::vector<IndexTarget*>* IndexTargets,
+ indexRecords* MetaIndexParser,
HashStringList const &ExpectedHashes=HashStringList(),
pkgAcqMetaBase *TransactionManager=NULL)
- : Item(Owner, ExpectedHashes, TransactionManager) {};
+ : Item(Owner, ExpectedHashes, TransactionManager),
+ MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets),
+ AuthPass(false), IMSHit(false) {};
};
+/** \brief An acquire item that downloads the detached signature {{{
+ * of a meta-index (Release) file, then queues up the release
+ * file itself.
+ *
+ * \todo Why protected members?
+ *
+ * \sa pkgAcqMetaIndex
+ */
+class pkgAcqMetaSig : public pkgAcqMetaBase
+{
+ void *d;
+
+ protected:
+
+ /** \brief The URI of the signature file. Unlike Desc.URI, this is
+ * never modified; it is used to determine the file that is being
+ * downloaded.
+ */
+ std::string RealURI;
+
+ /** \brief The file we need to verify */
+ std::string MetaIndexFile;
+
+ /** \brief Long URI description used in the acquire system */
+ std::string URIDesc;
+
+ /** \brief Short URI description used in the acquire system */
+ std::string ShortDesc;
+
+ 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,
+ pkgAcquire::MethodConfig *Cnf);
+ virtual std::string Custom600Headers() const;
+ virtual std::string DescURI() {return RealURI; };
+
+ /** \brief Create a new pkgAcqMetaSig. */
+ pkgAcqMetaSig(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
+ std::string URI,std::string URIDesc, std::string ShortDesc,
+ std::string MetaIndexFile,
+ const std::vector<IndexTarget*>* IndexTargets,
+ indexRecords* MetaIndexParser);
+ virtual ~pkgAcqMetaSig();
+};
+ /*}}}*/
/** \brief An item that is responsible for downloading the meta-index {{{
* file (i.e., Release) itself and verifying its signature.
*/
std::string SigFile;
- /** \brief The index files to download. */
- const std::vector<IndexTarget*>* IndexTargets;
-
- /** \brief The parser for the meta-index file. */
- indexRecords* MetaIndexParser;
-
- /** \brief If \b true, the index's signature is currently being verified.
- */
- bool AuthPass;
- // required to deal gracefully with problems caused by incorrect ims hits
- bool IMSHit;
-
/** \brief Check that the release file is a release file for the
* correct distribution.
*
*/
void AuthDone(std::string Message);
- /** \brief Starts downloading the individual index files.
- *
- * \param verify If \b true, only indices whose expected hashsum
- * can be determined from the meta-index will be downloaded, and
- * the hashsums of indices will be checked (reporting
- * #StatAuthError if there is a mismatch). If verify is \b false,
- * no hashsum checking will be performed.
- */
- void QueueIndexes(bool verify);
+ std::string URIDesc;
+ std::string ShortDesc;
/** \brief The URI of the meta-index file for the detached signature */
std::string MetaIndexSigURI;
void Init(std::string URIDesc, std::string ShortDesc);
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,
pkgAcquire::MethodConfig *Cnf);
virtual std::string Custom600Headers() const;
- virtual std::string DescURI() const {return RealURI; };
+ virtual std::string DescURI() {return RealURI; };
virtual void Finished();
/** \brief Create a new pkgAcqMetaIndex. */
public:
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
virtual std::string Custom600Headers() const;
- 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);
/** \brief Create a new pkgAcqMetaClearSig. */
/** \brief Pointer to the IndexTarget data
*/
const struct IndexTarget * Target;
+
+ /** \brief Pointer to the indexRecords parser */
indexRecords *MetaIndexParser;
+
/** \brief The MetaIndex Key */
std::string MetaKey;
+ /** \brief The URI of the index file to recreate at our end (either
+ * by downloading it or by applying partial patches).
+ */
+ std::string RealURI;
+
+ bool VerifyHashByMetaKey(HashStringList const &Hashes);
+
pkgAcqBaseIndex(pkgAcquire *Owner,
pkgAcqMetaBase *TransactionManager,
struct IndexTarget const * const Target,
/** \brief If \b true, debugging information will be written to std::clog. */
bool Debug;
- /** \brief The URI of the index file to recreate at our end (either
- * by downloading it or by applying partial patches).
- */
- std::string RealURI;
-
/** \brief The index file which will be patched to generate the new
* file.
*/
*/
std::string Description;
+ /** \brief If the copy step of the packages file is done
+ */
+ bool PackagesFileReadyInPartial;
+
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,
pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return RealURI + "Index";};
+ virtual std::string DescURI() {return RealURI + "Index";};
virtual std::string Custom600Headers() const;
/** \brief Parse the Index file for a set of Packages diffs.
*/
bool Debug;
- /** \brief URI of the package index file that is being
- * reconstructed.
- */
- std::string RealURI;
-
/** \brief description of the file being downloaded. */
std::string Description;
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return RealURI + "Index";};
+ virtual std::string DescURI() {return RealURI + "Index";};
/** \brief Create an index merge-diff item.
*
*/
bool Debug;
- /** \brief The URI of the package index file that is being
- * reconstructed.
- */
- std::string RealURI;
-
/** A description of the file being downloaded. */
std::string Description;
virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return RealURI + "Index";};
+ virtual std::string DescURI() {return RealURI + "IndexDiffs";};
/** \brief Create an index diff item.
*
protected:
- /** \brief If \b true, the index file has been decompressed. */
- bool Decompression;
-
- /** \brief If \b true, the partially downloaded file will be
- * removed when the download completes.
+ /** \brief The stages the method goes through
+ *
+ * The method first downloads the indexfile, then its decompressed (or
+ * copied) and verified
*/
- bool Erase;
+ enum AllStages {
+ STAGE_DOWNLOAD,
+ STAGE_DECOMPRESS_AND_VERIFY,
+ };
+ AllStages Stage;
- // FIXME:
- // Unused, used to be used to verify that "Packages: " header was there
- bool __DELME_ON_NEXT_ABI_BREAK_Verify;
+ /** \brief Handle what needs to be done when the download is done */
+ void StageDownloadDone(std::string Message,
+ HashStringList const &Hashes,
+ pkgAcquire::MethodConfig *Cfg);
- /** \brief The object that is actually being fetched (minus any
- * compression-related extensions).
+ /** \brief Handle what needs to be done when the decompression/copy is
+ * done
*/
- std::string RealURI;
+ void StageDecompressDone(std::string Message,
+ HashStringList const &Hashes,
+ pkgAcquire::MethodConfig *Cfg);
+
+ /** \brief If \b set, this partially downloaded file will be
+ * removed when the download completes.
+ */
+ std::string EraseFileName;
/** \brief The compression-related file extensions that are being
* added to the downloaded file one by one if first fails (e.g., "gz bz2").
*/
- std::string CompressionExtension;
+ std::string CompressionExtensions;
+ /** \brief The actual compression extension currently used */
+ std::string CurrentCompressionExtension;
/** \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() const {return Desc.URI;};
+ virtual std::string DescURI() {return Desc.URI;};
/** \brief Create a pkgAcqIndex.
*
}
};
/*}}}*/
-
-/** \brief An acquire item that downloads the detached signature {{{
- * of a meta-index (Release) file, then queues up the release
- * file itself.
- *
- * \todo Why protected members?
- *
- * \sa pkgAcqMetaIndex
- */
-class pkgAcqMetaSig : public pkgAcqMetaBase
-{
- void *d;
-
- protected:
- /** \brief The last good signature file */
- std::string LastGoodSig;
-
- /** \brief The URI of the signature file. Unlike Desc.URI, this is
- * never modified; it is used to determine the file that is being
- * downloaded.
- */
- std::string RealURI;
-
- /** \brief A package-system-specific parser for the meta-index file. */
- indexRecords* MetaIndexParser;
-
- /** \brief The file we need to verify */
- std::string MetaIndexFile;
-
- /** \brief The index files which should be looked up in the meta-index
- * and then downloaded.
- *
- * \todo Why a list of pointers instead of a list of structs?
- */
- const std::vector<IndexTarget*>* IndexTargets;
-
- /** \brief If we are in fetching or download state */
- bool AuthPass;
-
- /** \brief Was this file already on disk */
- bool IMSHit;
-
- 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,
- pkgAcquire::MethodConfig *Cnf);
- virtual std::string Custom600Headers() const;
- virtual std::string DescURI() const {return RealURI; };
-
- /** \brief Create a new pkgAcqMetaSig. */
- pkgAcqMetaSig(pkgAcquire *Owner,
- pkgAcqMetaBase *TransactionManager,
- std::string URI,std::string URIDesc, std::string ShortDesc,
- std::string MetaIndexFile,
- const std::vector<IndexTarget*>* IndexTargets,
- indexRecords* MetaIndexParser);
- virtual ~pkgAcqMetaSig();
-};
- /*}}}*/
/** \brief An item that is responsible for fetching a package file. {{{
*
* If the package file already exists in the cache, nothing will be
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return Desc.URI;};
- virtual std::string ShortDesc() const {return Desc.ShortDesc;};
+ virtual std::string DescURI() {return Desc.URI;};
+ virtual std::string ShortDesc() {return Desc.ShortDesc;};
virtual void Finished();
virtual bool IsTrusted() const;
virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
virtual void Done(std::string Message,unsigned long long Size, HashStringList const &CalcHashes,
pkgAcquire::MethodConfig *Cnf);
- virtual std::string DescURI() const {return Desc.URI;};
+ virtual std::string DescURI() {return Desc.URI;};
virtual std::string Custom600Headers() const;
/** \brief Create a new pkgAcqFile object.