]> git.proxmox.com Git - proxmox-apt.git/commitdiff
repo: make suite_variant helper more general
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 29 Jul 2021 12:25:49 +0000 (14:25 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 29 Jul 2021 16:00:38 +0000 (18:00 +0200)
use the first appearance of '-' or '/' to detect the variant instead
of keeping a list of possible variants, which would need to include
things like "-proposed-updates-debug".

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/repositories/repository.rs

index fc16327f8ba7ae315526248d013ce6e67e4dc904..d85f063e047fa1a1b8251d2217942877158f6ffa 100644 (file)
@@ -433,16 +433,12 @@ fn host_from_uri(uri: &str) -> Option<&str> {
 }
 
 /// Splits the suite into its base part and variant.
+/// Does not expect the base part to contain either `-` or `/`.
 fn suite_variant(suite: &str) -> (&str, &str) {
-    let variants = ["-backports-sloppy", "-backports", "-updates", "/updates"];
-
-    for variant in variants.iter() {
-        if let Some(base) = suite.strip_suffix(variant) {
-            return (base, variant);
-        }
+    match suite.find(&['-', '/'][..]) {
+        Some(n) => (&suite[0..n], &suite[n..]),
+        None => (suite, ""),
     }
-
-    (suite, "")
 }
 
 /// Strips existing double quotes from the string first, and then adds double quotes at