[pve-devel] [PATCH proxmox master stable-2 1/2] apt: repos: extend `Codename` by `Unknown` variant

Fiona Ebner f.ebner at proxmox.com
Tue Feb 6 09:29:33 CET 2024


Am 05.02.24 um 18:08 schrieb Christian Ebner:
> Instead of returning an Option for the Codename variant, with None for
> unknowns, extend the enum by an Unknown variant with additional internal
> type to avoid misuse of this variant.
> 
> Co-authored-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
>  proxmox-apt/src/repositories/file.rs    | 12 +++--
>  proxmox-apt/src/repositories/release.rs | 61 +++++++++++++++----------
>  2 files changed, 46 insertions(+), 27 deletions(-)
> 
> diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs
> index b4c6b08..b8a2c7f 100644
> --- a/proxmox-apt/src/repositories/file.rs
> +++ b/proxmox-apt/src/repositories/file.rs
> @@ -405,10 +405,14 @@ impl APTRepositoryFile {
>                      add_info("warning", message_old(base_suite));
>                  }
>  
> -                if Some(codename) == current_codename.next() {
> -                    add_info("ignore-pre-upgrade-warning", message_new(base_suite));
> -                } else if codename > current_codename {
> -                    add_info("warning", message_new(base_suite));
> +                match current_codename.next() {
> +                    name if name == codename => {
> +                        add_info("ignore-pre-upgrade-warning", message_new(base_suite));
> +                    }
> +                    DebianCodename::Unknown(_, _) if codename > current_codename => {
> +                        add_info("warning", message_new(base_suite));
> +                    }
> +                    _ => {}

Like this, the warning is lost when we match a known codename that is
newer than the current one. What is the issue with the current code you
are trying to address?

As for the match, you could pull in the case where the suite is older
(the if block just above this code) and rather do an exhaustive match.




More information about the pve-devel mailing list