[PATCH] setup: Report progress correctly when amount of data is more than 2GB

Jon TURNEY jon.turney@dronecode.org.uk
Wed Jan 16 20:30:00 GMT 2013


As noted elsewhere ([1],[2]), setup does not report the overall installation
progress correctly when the total size of packages being installed is more
than 2GB.

It seems that it is now possible to exceed that limit by asking setup to
install everything, which downloads about 4.8 GB. (Note that this includes all
source-only packages, and all debuginfo packages, which is possibly not what
is usually wanted)

Attached is a fairly minimal patch to fix the progress reporting.

[1] http://cygwin.com/ml/cygwin-apps/2011-04/msg00047.html
[2] http://cygwin.com/ml/cygwin/2013-01/msg00154.html
-------------- next part --------------
>From dc94d6eb1a861dd157d90336d99586853e3df41a Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney@dronecode.org.uk>
Date: Wed, 16 Jan 2013 13:25:06 +0000
Subject: [PATCH] Report progress correctly when amount of data is more than
 2GB

Use long long int for progress bar 2 (overall progress), so it works correctly
when the total amount of data being downloaded/md5summed/installed is more than
2GB.

There are still errors which will occur when an individual package exceeds 2GB

2013-01-16  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* threebar.cc (ThreeBarProgressPage::SetBar2): Change from long int to
	long long int to handle more than 2GB of data.
	* threebar.h (ThreeBarProgressPage::SetBar2): Update prototype.
	* install.cc: Change md5sum and install counters to long long int.
	* geturl.cc: Change download counter to long long int.
	* geturl.h: Ditto.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
 geturl.cc   |    4 ++--
 geturl.h    |    4 ++--
 install.cc  |    8 ++++----
 threebar.cc |    2 +-
 threebar.h  |    2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/geturl.cc b/geturl.cc
index f510d60..cd1b043 100644
--- a/geturl.cc
+++ b/geturl.cc
@@ -55,8 +55,8 @@ extern ThreeBarProgressPage Progress;
 static int max_bytes = 0;
 static int is_local_install = 0;
 
-int total_download_bytes = 0;
-int total_download_bytes_sofar = 0;
+long long int total_download_bytes = 0;
+long long int total_download_bytes_sofar = 0;
 
 static DWORD start_tics;
 
diff --git a/geturl.h b/geturl.h
index d82da79..f4e963e 100644
--- a/geturl.h
+++ b/geturl.h
@@ -21,8 +21,8 @@
 
 #include <string>
 
-extern int total_download_bytes;
-extern int total_download_bytes_sofar;
+extern long long int total_download_bytes;
+extern long long int total_download_bytes_sofar;
 
 class io_stream;
 
diff --git a/install.cc b/install.cc
index 5e3331a..4ad11da 100644
--- a/install.cc
+++ b/install.cc
@@ -68,8 +68,8 @@ using namespace std;
 
 extern ThreeBarProgressPage Progress;
 
-static int total_bytes = 0;
-static int total_bytes_sofar = 0;
+static long long int total_bytes = 0;
+static long long int total_bytes_sofar = 0;
 static int package_bytes = 0;
 
 static BoolOption NoReplaceOnReboot (false, 'r', "no-replaceonreboot",
@@ -631,7 +631,7 @@ do_install_thread (HINSTANCE h, HWND owner)
 
   /* Calculate the amount of data to md5sum */
   Progress.SetText1("Calculating...");
-  int md5sum_total_bytes = 0;
+  long long int md5sum_total_bytes = 0;
   for (packagedb::packagecollection::iterator i = db.packages.begin ();
        i != db.packages.end (); ++i)
   {
@@ -650,7 +650,7 @@ do_install_thread (HINSTANCE h, HWND owner)
 
   /* md5sum the packages, build lists of packages to install and uninstall
      and calculate the total amount of data to install */
-  int md5sum_total_bytes_sofar = 0;
+  long long int md5sum_total_bytes_sofar = 0;
   for (packagedb::packagecollection::iterator i = db.packages.begin ();
        i != db.packages.end (); ++i)
   {
diff --git a/threebar.cc b/threebar.cc
index b88dd38..a5fcece 100644
--- a/threebar.cc
+++ b/threebar.cc
@@ -106,7 +106,7 @@ ThreeBarProgressPage::SetBar1 (long progress, long max)
 }
 
 void
-ThreeBarProgressPage::SetBar2 (long progress, long max)
+ThreeBarProgressPage::SetBar2 (long long progress, long long max)
 {
   int percent = (int) (100.0 * ((double) progress) / (double) max);
   SendMessage (ins_iprogress, PBM_SETPOS, (WPARAM) percent, 0);
diff --git a/threebar.h b/threebar.h
index 225703a..744eb1d 100644
--- a/threebar.h
+++ b/threebar.h
@@ -75,7 +75,7 @@ public:
   void SetText4 (const TCHAR * t);
 
   void SetBar1 (long progress, long max = 100);
-  void SetBar2 (long progress, long max = 100);
+  void SetBar2 (long long progress, long long max = 100);
   void SetBar3 (long progress, long max = 100);
 
   void SetActivateTask (int t)
-- 
1.7.9



More information about the Cygwin-apps mailing list