mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
[yabridgectl] Add a blacklist #88
This lets you skip single plugins and entire directories during the indexing process.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use colored::Colorize;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
@@ -43,7 +43,7 @@ pub fn remove_directory(config: &mut Config, path: &Path) -> Result<()> {
|
||||
|
||||
// Ask the user to remove any leftover files to prevent possible future problems and out of date
|
||||
// copies
|
||||
let orphan_files = files::index(path).so_files;
|
||||
let orphan_files = files::index(path, &HashSet::new()).so_files;
|
||||
if !orphan_files.is_empty() {
|
||||
println!(
|
||||
"Warning: Found {} leftover .so files still in this directory:",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use rayon::prelude::*;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
use std::env;
|
||||
use std::fmt::Display;
|
||||
use std::fs;
|
||||
@@ -70,6 +70,11 @@ pub struct Config {
|
||||
/// Always skip post-installation setup checks. This can be set temporarily by passing the
|
||||
/// `--no-verify` option to `yabridgectl sync`.
|
||||
pub no_verify: bool,
|
||||
/// Files and directories that should be skipped during the indexing process. If this contains a
|
||||
/// directory, then everything under that directory will also be skipped. Like with
|
||||
/// `plugin_dirs`, we're using a `BTreeSet` here because it looks nicer in the config file, even
|
||||
/// though a hash set would make much more sense.
|
||||
pub blacklist: BTreeSet<PathBuf>,
|
||||
/// The last known combination of Wine and yabridge versions that would work together properly.
|
||||
/// This is mostly to diagnose issues with older Wine versions (such as those in Ubuntu's repos)
|
||||
/// early on.
|
||||
@@ -155,6 +160,7 @@ impl Default for Config {
|
||||
yabridge_home: None,
|
||||
plugin_dirs: BTreeSet::new(),
|
||||
no_verify: false,
|
||||
blacklist: BTreeSet::new(),
|
||||
last_known_config: None,
|
||||
}
|
||||
}
|
||||
@@ -282,10 +288,12 @@ impl Config {
|
||||
/// Search for VST2 and VST3 plugins in all of the registered plugins directories. This will
|
||||
/// return an error if `winedump` could not be called.
|
||||
pub fn search_directories(&self) -> Result<BTreeMap<&Path, SearchResults>> {
|
||||
let blacklist: HashSet<&Path> = self.blacklist.iter().map(|p| p.as_path()).collect();
|
||||
|
||||
self.plugin_dirs
|
||||
.par_iter()
|
||||
.map(|path| {
|
||||
files::index(path)
|
||||
files::index(path, &blacklist)
|
||||
.search()
|
||||
.map(|search_results| (path.as_path(), search_results))
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ use aho_corasick::AhoCorasick;
|
||||
use anyhow::{Context, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use rayon::prelude::*;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fmt::Display;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
@@ -321,8 +321,10 @@ impl SearchResults {
|
||||
}
|
||||
|
||||
/// Find all `.dll`, `.vst3` and `.so` files under a directory. These results can be filtered down
|
||||
/// to actual VST2 plugins and VST3 modules using `search()`.
|
||||
pub fn index(directory: &Path) -> SearchIndex {
|
||||
/// to actual VST2 plugins and VST3 modules using `search()`. Any path found in the blacklist will
|
||||
/// be pruned immediately, so this can be used to both not index individual files and to skip an
|
||||
/// entire directory.
|
||||
pub fn index(directory: &Path, blacklist: &HashSet<&Path>) -> SearchIndex {
|
||||
let mut dll_files: Vec<PathBuf> = Vec::new();
|
||||
let mut vst3_files: Vec<PathBuf> = Vec::new();
|
||||
let mut so_files: Vec<NativeFile> = Vec::new();
|
||||
@@ -331,6 +333,7 @@ pub fn index(directory: &Path) -> SearchIndex {
|
||||
for (file_idx, entry) in WalkDir::new(directory)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
.filter_entry(|e| !blacklist.contains(e.path()))
|
||||
.filter_map(|e| e.ok())
|
||||
.filter(|e| !e.file_type().is_dir())
|
||||
.enumerate()
|
||||
|
||||
Reference in New Issue
Block a user