diff options
author | Daniel Hartwig <mandyke@gmail.com> | 2012-05-11 15:54:19 +0800 |
---|---|---|
committer | Daniel Hartwig <mandyke@gmail.com> | 2012-05-11 16:09:44 +0800 |
commit | eb9f6c23f7a3b4554531b3b8da2b5b05e0fe1da7 (patch) | |
tree | bc78d19b9dc3685f06c67dec5db34660e12e3dfd | |
parent | fcc61ba5e6a3b73f48b026ccb4b775d235f5ab41 (diff) | |
download | aptitude-eb9f6c23f7a3b4554531b3b8da2b5b05e0fe1da7.tar.gz |
Support really big files in the download system
This follows recent changes in apt which added support for
files greater than several gigabytes in size -- using the
'unsigned long long' type to store the file size.
Changelog download is restored as a result of this.
Closes: #669569
LP: #824708
-rw-r--r-- | NEWS | 20 | ||||
-rw-r--r-- | src/cmdline/cmdline_changelog.cc | 8 | ||||
-rw-r--r-- | src/cmdline/cmdline_download_progress_display.cc | 32 | ||||
-rw-r--r-- | src/cmdline/cmdline_prompt.cc | 2 | ||||
-rw-r--r-- | src/download_list.cc | 17 | ||||
-rw-r--r-- | src/download_list.h | 8 | ||||
-rw-r--r-- | src/download_thread.cc | 4 | ||||
-rw-r--r-- | src/download_thread.h | 2 | ||||
-rw-r--r-- | src/generic/apt/aptcache.h | 4 | ||||
-rw-r--r-- | src/generic/apt/download_queue.cc | 6 | ||||
-rw-r--r-- | src/generic/apt/download_queue.h | 4 | ||||
-rw-r--r-- | src/generic/apt/download_signal_log.cc | 2 | ||||
-rw-r--r-- | src/generic/apt/download_signal_log.h | 16 | ||||
-rw-r--r-- | src/generic/apt/pkg_changelog.cc | 4 | ||||
-rw-r--r-- | src/generic/controllers/acquire_download_progress.cc | 16 | ||||
-rw-r--r-- | src/generic/views/download_progress.h | 36 | ||||
-rw-r--r-- | src/generic/views/mocks/download_progress.h | 4 | ||||
-rw-r--r-- | src/view_changelog.cc | 4 | ||||
-rw-r--r-- | tests/test_cmdline_download_status_display.cc | 12 |
19 files changed, 105 insertions, 96 deletions
@@ -1,3 +1,23 @@ +[5/11/2012] +Version 0.6.8 "Never need a reason, + never need a rhyme" + +This version of aptitude requires apt 0.9 and will not build against +earlier releases. + +- New features: + + * [all]: Support really big files in the download system + + This follows recent changes in apt which added support for + files greater than several gigabytes in size -- using the + 'unsigned long long' type to store the file size. + +- Minor bugs: + + * [all]: Changelog downloading is restored + (Closes: #669569, LP: #824708) + [5/2/2012] Version 0.6.7 "I said 'Step pause turn pause pivot step step'" diff --git a/src/cmdline/cmdline_changelog.cc b/src/cmdline/cmdline_changelog.cc index 3dd70362..a2ea9e92 100644 --- a/src/cmdline/cmdline_changelog.cc +++ b/src/cmdline/cmdline_changelog.cc @@ -88,8 +88,8 @@ void set_name(temp::name n, temp::name *target) } void partial_download(const temp::name &name, - unsigned long currentSize, - unsigned long totalSize) + unsigned long long currentSize, + unsigned long long totalSize) { // Hack: ripped this code from AcqTextStatus. @@ -98,8 +98,8 @@ void set_name(temp::name n, temp::name *target) const int screen_width = term_metrics->get_screen_width(); - unsigned long TotalBytes = totalSize; - unsigned long CurrentBytes = currentSize; + unsigned long long TotalBytes = totalSize; + unsigned long long CurrentBytes = currentSize; std::ostringstream bufferStream; diff --git a/src/cmdline/cmdline_download_progress_display.cc b/src/cmdline/cmdline_download_progress_display.cc index 1588af95..e4c94f16 100644 --- a/src/cmdline/cmdline_download_progress_display.cc +++ b/src/cmdline/cmdline_download_progress_display.cc @@ -88,17 +88,17 @@ namespace aptitude void file_finished(const std::string &description, const boost::optional<unsigned long> &id); - void done(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate); + void done(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate); void media_change(const std::string &media, const std::string &drive, const sigc::slot1<void, bool> &k); - virtual void complete(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate); + virtual void complete(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate); }; download_progress::download_progress(bool _display_messages, @@ -199,9 +199,9 @@ namespace aptitude { } - void download_progress::done(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate) + void download_progress::done(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate) { if(display_messages) { @@ -244,9 +244,9 @@ namespace aptitude k(true); } - void download_progress::complete(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate) + void download_progress::complete(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate) { } @@ -332,8 +332,8 @@ namespace aptitude void operator()(const file_progress &progress) const { - const unsigned long current_size = progress.get_current_size(); - const unsigned long total_size = progress.get_total_size(); + const unsigned long long current_size = progress.get_current_size(); + const unsigned long long total_size = progress.get_total_size(); const bool complete = progress.get_complete(); const std::string &description = progress.get_description(); @@ -420,11 +420,11 @@ namespace aptitude void download_status_display_impl::display_status(const download_progress::status &status) { typedef views::download_progress::status::worker_status worker_status; - const double download_rate = status.get_download_rate(); + const unsigned long long download_rate = status.get_download_rate(); const std::vector<worker_status> &active_downloads = status.get_active_downloads(); const double fraction_complete = status.get_fraction_complete(); - const unsigned long time_remaining = status.get_time_remaining(); + const unsigned long long time_remaining = status.get_time_remaining(); const int percent = as_percent(fraction_complete); diff --git a/src/cmdline/cmdline_prompt.cc b/src/cmdline/cmdline_prompt.cc index c65f779e..25fadaa7 100644 --- a/src/cmdline/cmdline_prompt.cc +++ b/src/cmdline/cmdline_prompt.cc @@ -66,7 +66,7 @@ using boost::shared_ptr; struct fetchinfo { - double FetchBytes, FetchPBytes, DebBytes; + unsigned long long FetchBytes, FetchPBytes, DebBytes; fetchinfo() : FetchBytes(0), FetchPBytes(0), DebBytes(0) diff --git a/src/download_list.cc b/src/download_list.cc index 876aed87..90151654 100644 --- a/src/download_list.cc +++ b/src/download_list.cc @@ -58,12 +58,12 @@ namespace cwidget */ const int download_list_spinner_interval = 1; -download_list::workerinf::workerinf(const wstring &_msg, unsigned long _current, unsigned long _total) +download_list::workerinf::workerinf(const wstring &_msg, unsigned long long _current, unsigned long long _total) :msg(_msg), current(_current), total(_total) { } -download_list::workerinf::workerinf(const string &_msg, unsigned long _current, unsigned long _total) +download_list::workerinf::workerinf(const string &_msg, unsigned long long _current, unsigned long long _total) :msg(cw::util::transcode(_msg)), current(_current), total(_total) { } @@ -73,9 +73,9 @@ static cw::widget_ref download_summary(const download_list_ref &l, bool failed, bool already_cancelled, const sigc::slot0<void> &cancel_slot, - double FetchedBytes, - unsigned long ElapsedTime, - double CurrentCPS) + unsigned long long FetchedBytes, + unsigned long long ElapsedTime, + unsigned long long CurrentCPS) { vector<cw::fragment *> fragments; @@ -221,12 +221,13 @@ void download_list::paint(const cw::style &st) if(display_cumulative_progress) { - unsigned long ETA = 0; + unsigned long long ETA = 0; if(CurrentCPS > 0) - ETA=(unsigned long)((TotalBytes-CurrentBytes)/CurrentCPS); + ETA = (TotalBytes - CurrentBytes) / CurrentCPS; - double fraction_complete = (double(CurrentBytes + CurrentItems))/(TotalBytes + TotalItems); + double fraction_complete = + ((double) (CurrentBytes + CurrentItems)) / ((double) (TotalBytes + TotalItems)); // Clamp to [0,1] if(fraction_complete > 1) diff --git a/src/download_list.h b/src/download_list.h index e8520dc6..1ce88631 100644 --- a/src/download_list.h +++ b/src/download_list.h @@ -48,10 +48,10 @@ class download_list:public cwidget::widgets::widget struct workerinf { std::wstring msg; - unsigned long current, total; + unsigned long long current, total; - workerinf(const std::wstring &_msg, unsigned long _current, unsigned long _total); - workerinf(const std::string &_msg, unsigned long _current, unsigned long _total); + workerinf(const std::wstring &_msg, unsigned long long _current, unsigned long long _total); + workerinf(const std::string &_msg, unsigned long long _current, unsigned long long _total); }; typedef std::pair<std::wstring, cwidget::style> msg; @@ -100,7 +100,7 @@ class download_list:public cwidget::widgets::widget // We have to mirror the download_signal_log's information, since // we're only synchronous with it in the log callbacks. unsigned long TotalItems, CurrentItems; - double CurrentCPS, TotalBytes, CurrentBytes; + unsigned long long CurrentCPS, TotalBytes, CurrentBytes; /** \brief When the download started, as returned by time(2). * diff --git a/src/download_thread.cc b/src/download_thread.cc index 7fa22053..0c660e2d 100644 --- a/src/download_thread.cc +++ b/src/download_thread.cc @@ -132,8 +132,8 @@ RVal do_foreground_execute(C *inst, return return_box.take(); } -void background_status::Fetched(unsigned long Size, - unsigned long ResumePoint) +void background_status::Fetched(unsigned long long Size, + unsigned long long ResumePoint) { do_foreground_execute(real_status, Size, ResumePoint, &download_signal_log::Fetched, diff --git a/src/download_thread.h b/src/download_thread.h index 1159e29c..6fc431ea 100644 --- a/src/download_thread.h +++ b/src/download_thread.h @@ -61,7 +61,7 @@ class background_status : public pkgAcquireStatus post_thunk_func post_thunk; public: - void Fetched(unsigned long Size, unsigned long ResumePoint); + void Fetched(unsigned long long Size, unsigned long long ResumePoint); bool MediaChange(std::string Media, std::string Drive); void IMSHit(pkgAcquire::ItemDesc &); void Fetch(pkgAcquire::ItemDesc &); diff --git a/src/generic/apt/aptcache.h b/src/generic/apt/aptcache.h index 3cbca962..df2857e5 100644 --- a/src/generic/apt/aptcache.h +++ b/src/generic/apt/aptcache.h @@ -224,8 +224,8 @@ public: StateCache *PkgState; unsigned char *DepState; aptitude_state *AptitudeState; - double iUsrSize; - double iDownloadSize; + signed long long iUsrSize; + unsigned long long iDownloadSize; unsigned long iInstCount; unsigned long iDelCount; unsigned long iKeepCount; diff --git a/src/generic/apt/download_queue.cc b/src/generic/apt/download_queue.cc index 0c0b184c..3efce494 100644 --- a/src/generic/apt/download_queue.cc +++ b/src/generic/apt/download_queue.cc @@ -153,8 +153,8 @@ namespace aptitude /** \brief Invoke the partial download callback on each listener. */ void invoke_partial_download(const temp::name &filename, - unsigned long currentSize, - unsigned long totalSize) const + unsigned long long currentSize, + unsigned long long totalSize) const { for(std::list<listener>::const_iterator it = listeners.begin(); it != listeners.end(); ++it) @@ -284,7 +284,7 @@ namespace aptitude } void Done(std::string Message, - unsigned long Size, + unsigned long long Size, std::string CalcHash, pkgAcquire::MethodConfig *Cnf) { diff --git a/src/generic/apt/download_queue.h b/src/generic/apt/download_queue.h index f734f8bc..315563bd 100644 --- a/src/generic/apt/download_queue.h +++ b/src/generic/apt/download_queue.h @@ -71,8 +71,8 @@ namespace aptitude * The default implementation does nothing. */ virtual void partial_download(const temp::name &filename, - unsigned long currentSize, - unsigned long totalSize) + unsigned long long currentSize, + unsigned long long totalSize) { } diff --git a/src/generic/apt/download_signal_log.cc b/src/generic/apt/download_signal_log.cc index 1f1c9621..ef9dd99a 100644 --- a/src/generic/apt/download_signal_log.cc +++ b/src/generic/apt/download_signal_log.cc @@ -40,7 +40,7 @@ static void set_bool(bool val, int *out) *out = val ? 1 : 0; } -void download_signal_log::Fetched(unsigned long Size, unsigned long ResumePoint) +void download_signal_log::Fetched(unsigned long long Size, unsigned long long ResumePoint) { pkgAcquireStatus::Fetched(Size, ResumePoint); diff --git a/src/generic/apt/download_signal_log.h b/src/generic/apt/download_signal_log.h index a48edff0..a14ac819 100644 --- a/src/generic/apt/download_signal_log.h +++ b/src/generic/apt/download_signal_log.h @@ -66,18 +66,18 @@ public: struct timeval &get_time() {return Time;} struct timeval &get_start_time() {return StartTime;} - double get_last_bytes() {return LastBytes;} - double get_currentCPS() {return CurrentCPS;} - double get_current_bytes() {return CurrentBytes;} - double get_total_bytes() {return TotalBytes;} - double get_fetched_bytes() {return FetchedBytes;} - unsigned long get_elapsed_time() {return ElapsedTime;} + unsigned long long get_last_bytes() {return LastBytes;} + unsigned long long get_currentCPS() {return CurrentCPS;} + unsigned long long get_current_bytes() {return CurrentBytes;} + unsigned long long get_total_bytes() {return TotalBytes;} + unsigned long long get_fetched_bytes() {return FetchedBytes;} + unsigned long long get_elapsed_time() {return ElapsedTime;} unsigned long get_total_items() {return TotalItems;} unsigned long get_current_items() {return CurrentItems;} void set_update(bool _Update) {Update=_Update;} - sigc::signal3<void, unsigned long, unsigned long, + sigc::signal3<void, unsigned long long, unsigned long long, download_signal_log &> Fetched_sig; sigc::signal4<void, std::string, std::string, download_signal_log &, const sigc::slot1<void, bool> &> MediaChange_sig; @@ -92,7 +92,7 @@ public: const sigc::slot0<void> &> Stop_sig; sigc::signal1<void, download_signal_log &> Complete_sig; - void Fetched(unsigned long Size, unsigned long ResumePoint); + void Fetched(unsigned long long Size, unsigned long long ResumePoint); void MediaChange(const std::string &Media, const std::string &Drive, const sigc::slot1<void, bool> &k); bool MediaChange(std::string Media, std::string Drive); diff --git a/src/generic/apt/pkg_changelog.cc b/src/generic/apt/pkg_changelog.cc index 5f17c753..8724d24c 100644 --- a/src/generic/apt/pkg_changelog.cc +++ b/src/generic/apt/pkg_changelog.cc @@ -305,8 +305,8 @@ namespace aptitude } void partial_download(const temp::name &filename, - unsigned long currentSize, - unsigned long totalSize) + unsigned long long currentSize, + unsigned long long totalSize) { parent->partial_download(filename, currentSize, totalSize); } diff --git a/src/generic/controllers/acquire_download_progress.cc b/src/generic/controllers/acquire_download_progress.cc index 8bc96876..12f8d0f1 100644 --- a/src/generic/controllers/acquire_download_progress.cc +++ b/src/generic/controllers/acquire_download_progress.cc @@ -165,20 +165,20 @@ namespace aptitude } } - const double download_rate = manager.get_currentCPS(); + const unsigned long long download_rate = manager.get_currentCPS(); - const double current_bytes = manager.get_current_bytes(); - const double current_items = manager.get_current_items(); - const double total_bytes = manager.get_total_bytes(); - const double total_items = manager.get_total_items(); + const unsigned long long current_bytes = manager.get_current_bytes(); + const unsigned long long total_bytes = manager.get_total_bytes(); + const unsigned long current_items = manager.get_current_items(); + const unsigned long total_items = manager.get_total_items(); const double fraction_complete = - ((double) (current_bytes + current_items)) / (total_bytes + total_items); + ((double) (current_bytes + current_items)) / ((double) (total_bytes + total_items)); - const unsigned long time_remaining = + const unsigned long long time_remaining = download_rate == 0 ? 0 - : (total_bytes - current_bytes) / download_rate; + : ((unsigned long long) (total_bytes - current_bytes)) / download_rate; return boost::make_shared<status>(manager.get_currentCPS(), active_downloads, diff --git a/src/generic/views/download_progress.h b/src/generic/views/download_progress.h index 1b6c919a..3e411495 100644 --- a/src/generic/views/download_progress.h +++ b/src/generic/views/download_progress.h @@ -48,8 +48,8 @@ namespace aptitude /** \brief Represents the download progress of a single file. */ class file_progress { - unsigned long current_size; - unsigned long total_size; + unsigned long long current_size; + unsigned long long total_size; bool complete; std::string description; @@ -57,8 +57,8 @@ namespace aptitude std::string mode; public: - file_progress(unsigned long _current_size, - unsigned long _total_size, + file_progress(unsigned long long _current_size, + unsigned long long _total_size, bool _complete, const std::string &_description, const boost::optional<unsigned long> &_id, @@ -74,10 +74,10 @@ namespace aptitude } /** \brief Get the number of bytes that have been downloaded. */ - unsigned long get_current_size() const { return current_size; } + unsigned long long get_current_size() const { return current_size; } /** \brief Get the total size of the file. */ - unsigned long get_total_size() const { return total_size; } + unsigned long long get_total_size() const { return total_size; } /** \return \b true if the file has been successfully fetched * according to the download backend. @@ -113,16 +113,16 @@ namespace aptitude typedef boost::variant<file_progress, std::string> worker_status; private: - const double download_rate; + const unsigned long long download_rate; const std::vector<worker_status> active_downloads; const double fraction_complete; - const unsigned long time_remaining; + const unsigned long long time_remaining; public: - status(const double _download_rate, + status(const unsigned long long _download_rate, const std::vector<worker_status> &_active_downloads, const double _fraction_complete, - const unsigned long _time_remaining) + const unsigned long long _time_remaining) : download_rate(_download_rate), active_downloads(_active_downloads), fraction_complete(_fraction_complete), @@ -131,7 +131,7 @@ namespace aptitude } /** \brief Get the current download speed in bytes per second. */ - double get_download_rate() const { return download_rate; } + unsigned long long get_download_rate() const { return download_rate; } /** \brief Get the currently active download processes. */ const std::vector<worker_status> &get_active_downloads() const @@ -147,7 +147,7 @@ namespace aptitude /** \brief Get the estimated number of seconds until the download * completes. */ - unsigned long get_time_remaining() const { return time_remaining; } + unsigned long long get_time_remaining() const { return time_remaining; } bool operator==(const status &other) const; bool operator!=(const status &other) const @@ -231,9 +231,9 @@ namespace aptitude * \todo Should the parameters be incorporated into a status * snapshot so that can be used instead? */ - virtual void done(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate) = 0; + virtual void done(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate) = 0; /** \brief Invoked when the install media should be replaced. * @@ -258,9 +258,9 @@ namespace aptitude * * \param latest_download_rate The final estimated download rate. */ - virtual void complete(double fetched_bytes, - unsigned long elapsed_time, - double latest_download_rate) = 0; + virtual void complete(unsigned long long fetched_bytes, + unsigned long long elapsed_time, + unsigned long long latest_download_rate) = 0; }; std::ostream &operator<<(std::ostream &out, diff --git a/src/generic/views/mocks/download_progress.h b/src/generic/views/mocks/download_progress.h index 31fd9283..3250abf8 100644 --- a/src/generic/views/mocks/download_progress.h +++ b/src/generic/views/mocks/download_progress.h @@ -46,14 +46,14 @@ namespace aptitude MOCK_METHOD1(update_progress, bool(const status &)); MOCK_METHOD3(file_started, void(const std::string &, const boost::optional<unsigned long> &, - const boost::optional<unsigned long> &)); + const boost::optional<unsigned long long> &)); MOCK_METHOD4(error, void(bool, const std::string &, const std::string &, const boost::optional<unsigned long> &)); MOCK_METHOD2(file_finished, void(const std::string &, const boost::optional<unsigned long> &)); - MOCK_METHOD3(done, void(double, unsigned long, double)); + MOCK_METHOD3(done, void(unsigned long long, unsigned long long, unsigned long long)); MOCK_METHOD3(media_change, void(const std::string &, const std::string &, const sigc::slot1<void, bool> &)); diff --git a/src/view_changelog.cc b/src/view_changelog.cc index caf5a320..8318a96f 100644 --- a/src/view_changelog.cc +++ b/src/view_changelog.cc @@ -373,8 +373,8 @@ public: } void partial_download(const temp::name &name, - unsigned long currentSize, - unsigned long totalSize) + unsigned long long currentSize, + unsigned long long totalSize) { cwidget::util::ref_ptr<refcounted_progress> p = download_progress->get_progress(); diff --git a/tests/test_cmdline_download_status_display.cc b/tests/test_cmdline_download_status_display.cc index 020e2817..3938a384 100644 --- a/tests/test_cmdline_download_status_display.cc +++ b/tests/test_cmdline_download_status_display.cc @@ -278,18 +278,6 @@ TEST_P(CmdlineDownloadStatusDisplayTest, HasCpsNoFilesNoProgressNoTimeEstimate) 0)); } -// Test that updating the progress produces correct results when the -// download rate indicator is negative. -TEST_P(CmdlineDownloadStatusDisplayTest, HasNegativeCpsNoFilesNoProgressNoTimeEstimate) -{ - EXPECT_MSG(L"0% [Working]"); - - status_display->display_status(status(-20 * 1000, - make_files(), - 0, - 0)); -} - // Test that updating the progress produces correct results with a // time estimate. TEST_P(CmdlineDownloadStatusDisplayTest, NoCpsNoFilesNoProgressHasTimeEstimate) |