From 1cd1c398d18b78f4aa9d882a5de5385f4538e0be Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 7 Apr 2010 16:38:18 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - add a parent-guarded "mkdir -p" as CreateDirectory() * apt-pkg/acquire.{cc,h}: - add a delayed constructor with Setup() for success reporting - check for and create directories in Setup if needed instead of error out unfriendly in the Constructor (Closes: #523920, #525783) - optional handle a lock file in Setup() * cmdline/apt-get.cc: - remove the lock file handling and let Acquire take care of it instead --- apt-pkg/acquire.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'apt-pkg/acquire.h') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 6c130c1b3..9e91a9f67 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -66,6 +66,8 @@ #ifndef PKGLIB_ACQUIRE_H #define PKGLIB_ACQUIRE_H +#include + #include #include @@ -161,7 +163,7 @@ class pkgAcquire QueueAccess} QueueMode; /** \brief If \b true, debugging information will be dumped to std::clog. */ - bool Debug; + bool const Debug; /** \brief If \b true, a download is currently in progress. */ bool Running; @@ -332,15 +334,22 @@ class pkgAcquire */ double PartialPresent(); - /** \brief Construct a new pkgAcquire. + /** \brief Delayed constructor * - * \param Log The progress indicator associated with this - * download, or \b NULL for none. This object is not owned by the + * \param Progress indicator associated with this download or + * \b NULL for none. This object is not owned by the * download process and will not be deleted when the pkgAcquire * object is destroyed. Naturally, it should live for at least as * long as the pkgAcquire object does. + * \param Lock defines a lock file that should be acquired to ensure + * only one Acquire class is in action at the time or an empty string + * if no lock file should be used. */ - pkgAcquire(pkgAcquireStatus *Log = 0); + bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = ""); + + /** \brief Construct a new pkgAcquire. */ + pkgAcquire(pkgAcquireStatus *Log) __deprecated; + pkgAcquire(); /** \brief Destroy this pkgAcquire object. * @@ -348,6 +357,18 @@ class pkgAcquire * this download. */ virtual ~pkgAcquire(); + + private: + /** \brief FD of the Lock file we acquire in Setup (if any) */ + int LockFD; + + /** \brief Ensure the existence of the given Path + * + * \param Parent directory of the Path directory - a trailing + * /apt/ will be removed before CreateDirectory call. + * \param Path which should exist after (successful) call + */ + bool CheckDirectory(string const &Parent, string const &Path) const; }; /** \brief Represents a single download source from which an item -- cgit v1.2.3 From 229fb1a3a35bade26cfff373087461d7a98aade3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 4 May 2010 17:05:23 +0200 Subject: * apt-pkg/contrib/weakptr.h: - add a class WeakPointable which allows one to register weak pointers to an object which will be set to NULL when the object is deallocated. * [ABI break] apt-pkg/acquire{-worker,-item,}.h: - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable. --- apt-pkg/acquire.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire.h') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 9e91a9f67..8e2c21151 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -67,6 +67,7 @@ #define PKGLIB_ACQUIRE_H #include +#include #include #include @@ -376,7 +377,7 @@ class pkgAcquire * * An item may have several assocated ItemDescs over its lifetime. */ -struct pkgAcquire::ItemDesc +struct pkgAcquire::ItemDesc : public WeakPointable { /** \brief The URI from which to download this item. */ string URI; -- cgit v1.2.3 From a3c4c81afe25377020470ff71c1362136437397c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 3 Jun 2010 10:45:58 +0200 Subject: * apt-pkg/depcache.cc: - switch i{Download,Usr}Size from double to (un)signed long long The biggest reason is that this saves a lot of float point operations we do in AddSizes() on integers. The only reason i see that this was a double is that it was 64bit long and can therefore store bigger values than int/long, but with the availablity of (un)signed long long we are now also at 64bit and can store sizes more than 8 Exabytes big - by the time this will be a limit the C/C++ Standard will have bigger types, hopefully. --- apt-pkg/acquire.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/acquire.h') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 8e2c21151..82be8b843 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -323,17 +323,17 @@ class pkgAcquire /** \return the total size in bytes of all the items included in * this download. */ - double TotalNeeded(); + unsigned long long TotalNeeded(); /** \return the size in bytes of all non-local items included in * this download. */ - double FetchNeeded(); + unsigned long long FetchNeeded(); /** \return the amount of data to be fetched that is already * present on the filesystem. */ - double PartialPresent(); + unsigned long long PartialPresent(); /** \brief Delayed constructor * -- cgit v1.2.3