Christian Franke wrote:
...
I made the false assumption that default_version=empty in set_action() always implies that the default version is not accessible. This is not the case for packages selected for installation before chooser is visible.

I'm working on a new fix for the "Ctrl+I pressed but current version is not accessible" case. ...

See attached patch. It also fixes the same problem for the "Category" view. Testing shows that the problem only affects the display of the version number as the solver later silently removes such install requests.


The correct logic is already in toggle_action(): Install the most recent accessible non-test ('naively_preferred') version.


I dropped this idea and aligned Ctrl+I behavior with "Install" from "Category" view instead. Toggle_action() behaves different in such corner cases as it always installs something.

From 7e1efd346e35898e3486fb84cf25b3885a2a16ec Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Tue, 27 Sep 2022 15:41:06 +0200
Subject: [PATCH] Ignore install requests if version is not accessible

This avoids that an empty "New" version is shown when install is
requested via "Install" from "Category" view or Ctrl+I and the
version is not accessible.
---
 package_meta.cc | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/package_meta.cc b/package_meta.cc
index 05b8946..ebfc947 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -539,6 +539,17 @@ packagemeta::select_action (int id, trusts const deftrust)
     {
       if (id == packagemeta::NoChange_action)
         set_action((packagemeta::_actions)id, installed);
+      else if (id == Install_action)
+       {
+         // Ignore install request if the default version is not accessible.
+         // This assumes that all available versions are already known.
+         // This is not always the case when set_action is called directly.
+         packageversion v = trustp (true, deftrust);
+         if (v.accessible ())
+           set_action(Install_action, v, true);
+         else
+           set_action(NoChange_action, installed);
+       }
       else
         set_action((packagemeta::_actions)id, trustp (true, deftrust), true);
     }
@@ -627,6 +638,7 @@ packagemeta::set_action (_actions action, packageversion 
const &default_version,
   else if (action == Install_action)
     {
       desired = default_version;
+      // If desired is empty, it will be set to the solver's preferred version 
later.
       if (desired)
        {
          if (desired != installed)
-- 
2.37.2

Reply via email to