This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 02/14] Factor out reading installed.db
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon Turney <jon dot turney at dronecode dot org dot uk>
- Date: Wed, 31 May 2017 11:50:03 +0100
- Subject: [PATCH setup 02/14] Factor out reading installed.db
- Authentication-results: sourceware.org; auth=none
- References: <20170531105015.162228-1-jon.turney@dronecode.org.uk>
Rather that doing implicitly the first time a packagedb is constructed, do
it explicitly at a certain point in time that is early enough.
---
ini.cc | 4 +++-
package_db.cc | 9 +++++++--
package_db.h | 1 +
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/ini.cc b/ini.cc
index 82990a2..1162b91 100644
--- a/ini.cc
+++ b/ini.cc
@@ -346,13 +346,15 @@ do_remote_ini (HWND owner)
static bool
do_ini_thread (HINSTANCE h, HWND owner)
{
+ packagedb db;
+ db.read();
+
size_t ini_count = 0;
if (source == IDC_SOURCE_LOCALDIR)
ini_count = do_local_ini (owner);
else
ini_count = do_remote_ini (owner);
- packagedb db;
db.upgrade();
if (ini_count == 0)
diff --git a/package_db.cc b/package_db.cc
index 00395d3..3d6d0de 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -45,10 +45,15 @@ using namespace std;
packagedb::packagedb ()
{
- io_stream *db = 0;
+}
+
+void
+packagedb::read ()
+{
if (!installeddbread)
{
- /* no parameters. Read in the local installation database. */
+ /* Read in the local installation database. */
+ io_stream *db = 0;
db = io_stream::open ("cygfile:///etc/setup/installed.db", "rt", 0);
installeddbread = 1;
if (!db)
diff --git a/package_db.h b/package_db.h
index d02dbc4..d26f8ad 100644
--- a/package_db.h
+++ b/package_db.h
@@ -63,6 +63,7 @@ class packagedb
{
public:
packagedb ();
+ void read();
/* 0 on success */
int flush ();
void upgrade ();
--
2.12.3