This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 06/14] Hoist scan() up from packageversion to packagemeta


---
 package_meta.cc    | 37 +++++++++++++++++++++++++++++++++++--
 package_meta.h     |  2 ++
 package_version.cc | 29 -----------------------------
 package_version.h  |  2 --
 4 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/package_meta.cc b/package_meta.cc
index f4678f0..425df59 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -44,6 +44,9 @@ using namespace std;
 
 #include <algorithm>
 #include "Generic.h"
+#include "download.h"
+#include "Exception.h"
+#include "resource.h"
 
 using namespace std;
 
@@ -582,6 +585,36 @@ packagemeta::logSelectionStatus() const
   pkg.logAllVersions();
 }
 
+/* scan for local copies of package */
+void
+packagemeta::scan (const packageversion &pkg, bool mirror_mode)
+{
+  /* Already have something */
+  if (!pkg)
+    return;
+
+  /* Remove mirror sites.
+   * FIXME: This is a bit of a hack.
+   */
+  try
+    {
+      if (!check_for_cached (*(pkg.source ()), mirror_mode)
+	  && ::source == IDC_SOURCE_LOCALDIR)
+	pkg.source ()->sites.clear ();
+    }
+  catch (Exception * e)
+    {
+      // We can ignore these, since we're clearing the source list anyway
+      if (e->errNo () == APPERR_CORRUPT_PACKAGE)
+	{
+	  pkg.source ()->sites.clear ();
+	  return;
+	}
+      // Unexpected exception.
+      throw e;
+    }
+}
+
 void
 packagemeta::ScanDownloadedFiles (bool mirror_mode)
 {
@@ -601,10 +634,10 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
 			   && (*i != pkg.installed
 			       || pkg.installed == pkg.curr
 			       || pkg.installed == pkg.exp);
-	  const_cast<packageversion &>(*i).scan (lazy_scan);
+	  scan (*i, lazy_scan);
 	  packageversion foo = *i;
 	  packageversion pkgsrcver = foo.sourcePackage ();
-	  pkgsrcver.scan (lazy_scan);
+	  scan (pkgsrcver, lazy_scan);
 
 	  /* For local installs, if there is no src and no bin, the version
 	   * is unavailable
diff --git a/package_meta.h b/package_meta.h
index 529b2a2..8041aa1 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -159,6 +159,8 @@ protected:
 private:
   std::string trustLabel(packageversion const &) const;
   std::vector <Script> scripts_;
+  static void scan (const packageversion &pkg, bool mirror_mode);
+
   bool _picked; /* true if desired version is to be (re)installed */
   bool _srcpicked;
 };
diff --git a/package_version.cc b/package_version.cc
index 3dcd7ea..6e8f692 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -23,8 +23,6 @@
 #include "state.h"
 #include "resource.h"
 #include <algorithm>
-#include "download.h"
-#include "Exception.h"
 #include "csu_util/version_compare.h"
 
 using namespace std;
@@ -232,33 +230,6 @@ packageversion::accessible() const
   return data->accessible();
 }
 
-void
-packageversion::scan (bool mirror_mode)
-{
-  if (!*this)
-    return;
-  /* Remove mirror sites.
-   * FIXME: This is a bit of a hack. a better way is to abstract
-   * the availability logic to the package
-   */
-  try
-    {
-      if (!check_for_cached (*(source ()), mirror_mode)
-	  && ::source == IDC_SOURCE_LOCALDIR)
-	source ()->sites.clear ();
-    }
-  catch (Exception * e)
-    {
-      // We can ignore these, since we're clearing the source list anyway
-      if (e->errNo () == APPERR_CORRUPT_PACKAGE)
-	{
-	  source ()->sites.clear ();
-	  return;
-	}
-      // Unexpected exception.
-      throw e;
-    }
-}
 
 int
 packageversion::compareVersions(const packageversion &a, const packageversion &b)
diff --git a/package_version.h b/package_version.h
index fc8a084..4c04d77 100644
--- a/package_version.h
+++ b/package_version.h
@@ -113,8 +113,6 @@ public:
   packagesource *source() const; /* where can we source the file from */
 
   bool accessible () const;
-  /* scan for local copies */
-  void scan (bool);
 
   /* ensure that the depends clause is satisfied */
   int set_requirements (trusts deftrust, size_t depth = 0);
-- 
2.12.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]