From b8eb031c77fbf08bfa0c99c6ad65ff61d3478bdf Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 14 Jul 2020 17:16:30 +0200 Subject: [PATCH] Store paths in a BTreeSet To avoid duplicates and to ensure that the order is stable. --- tools/yabridgectl/src/config.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs index 18e061ed..65cea29d 100644 --- a/tools/yabridgectl/src/config.rs +++ b/tools/yabridgectl/src/config.rs @@ -15,6 +15,7 @@ // along with this program. If not, see . use serde_derive::{Deserialize, Serialize}; +use std::collections::BTreeSet; use std::fs; use std::path::{Path, PathBuf}; use xdg::BaseDirectories; @@ -42,8 +43,9 @@ pub struct Config { /// look in `/usr/lib` and `$XDG_DATA_HOME/yabridge` since those are the expected locations for /// yabridge to be installed in. pub yabridge_home: Option, - /// Directories to search for Windows VST plugins. - pub plugin_dirs: Vec, + /// Directories to search for Windows VST plugins. We're using an ordered set here out of + /// convenience so we can't get duplicates and the config file is always sorted. + pub plugin_dirs: BTreeSet, } /// Specifies how yabridge will be set up for the found plugins. @@ -81,7 +83,7 @@ impl Config { let defaults = Config { method: InstallationMethod::Copy, yabridge_home: None, - plugin_dirs: Vec::new(), + plugin_dirs: BTreeSet::new(), }; // If no existing config file exists, then write a new config file with default