From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107499 invoked by alias); 31 May 2017 10:53:24 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 107454 invoked by uid 89); 31 May 2017 10:53:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: rgout04.bt.lon5.cpcloud.co.uk Received: from rgout0406.bt.lon5.cpcloud.co.uk (HELO rgout04.bt.lon5.cpcloud.co.uk) (65.20.0.219) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 May 2017 10:53:21 +0000 X-OWM-Source-IP: 86.141.128.130 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-Junkmail-Premium-Raw: score=8/50,refid=2.7.2:2017.5.13.91815:17:8.707,ip=,rules=NO_URI_FOUND, NO_CTA_URI_FOUND, NO_MESSAGE_ID, NO_URI_HTTPS, TO_MALFORMED Received: from localhost.localdomain (86.141.128.130) by rgout04.bt.lon5.cpcloud.co.uk (9.0.019.13-1) (authenticated as jonturney@btinternet.com) id 58482DA21281A32A; Wed, 31 May 2017 11:53:23 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 02/14] Factor out reading installed.db Date: Wed, 31 May 2017 10:53:00 -0000 Message-Id: <20170531105015.162228-3-jon.turney@dronecode.org.uk> In-Reply-To: <20170531105015.162228-1-jon.turney@dronecode.org.uk> References: <20170531105015.162228-1-jon.turney@dronecode.org.uk> X-SW-Source: 2017-05/txt/msg00163.txt.bz2 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