]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Fix packagemeta::ScanDownloadedFiles
authorJon Turney <jon.turney@dronecode.org.uk>
Tue, 6 Mar 2018 14:56:40 +0000 (14:56 +0000)
committerJon Turney <jon.turney@dronecode.org.uk>
Tue, 6 Mar 2018 20:42:45 +0000 (20:42 +0000)
packagemeta::scan clears the site list if the package was not found, and
packagemeta::ScanDownloadedFiles uses packageversion::accessible() to check
that.

Instead communicate via a return value

v2:
empty packages were always inaccessible, even though we returned early from
scan() without clearing the sites list, so return false in that case

package_meta.cc
package_meta.h

index c488e353b648e922769de250474f98795ef7fc8c..8a33bcb6c0a48330542cf723e21ced6ab6281eb7 100644 (file)
@@ -664,33 +664,30 @@ packagemeta::logSelectionStatus() const
 }
 
 /* scan for local copies of package */
-void
+bool
 packagemeta::scan (const packageversion &pkg, bool mirror_mode)
 {
-  /* Already have something */
+  /* empty version */
   if (!pkg)
-    return;
+    return false;
 
-  /* Remove mirror sites.
-   * FIXME: This is a bit of a hack.
-   */
   try
     {
       if (!check_for_cached (*(pkg.source ()), NULL, mirror_mode, false)
-         && ::source == IDC_SOURCE_LOCALDIR)
-       pkg.source ()->sites.clear ();
+          && ::source == IDC_SOURCE_LOCALDIR)
+        return false;
     }
   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;
-       }
+        return false;
+
       // Unexpected exception.
       throw e;
     }
+
+  return true;
 }
 
 void
@@ -712,15 +709,15 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
                           && (*i != pkg.installed
                               || pkg.installed == pkg.curr
                               || pkg.installed == pkg.exp);
-         scan (*i, lazy_scan);
+         bool accessible = scan (*i, lazy_scan);
          packageversion foo = *i;
          packageversion pkgsrcver = foo.sourcePackage ();
-         scan (pkgsrcver, lazy_scan);
+         bool src_accessible = scan (pkgsrcver, lazy_scan);
 
          /* For local installs, if there is no src and no bin, the version
           * is unavailable
           */
-         if (!i->accessible () && !pkgsrcver.accessible ()
+         if (!accessible && !src_accessible
              && *i != pkg.installed)
            {
              if (pkg.curr == *i)
index 32372e21a98f60e80916b706312e6ed5b687edc1..600a163307ec484fed0ca439f09f497481278a29 100644 (file)
@@ -170,7 +170,7 @@ protected:
 private:
   std::string trustLabel(packageversion const &) const;
   std::vector <Script> scripts_;
-  static void scan (const packageversion &pkg, bool mirror_mode);
+  static bool scan (const packageversion &pkg, bool mirror_mode);
 
   bool _picked; /* true if desired version is to be (re)installed */
   bool _srcpicked;
This page took 0.05034 seconds and 5 git commands to generate.