Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Scoop package count performance #113

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ num_cpus = "1.13.1"

[target.'cfg(target_os = "windows")'.dependencies]
local-ip-address = "0.4.4"
which = "4.2.2"
winreg = "0.10.1"
windows = { version = "0.29.0", features = [
"Win32_Foundation",
Expand Down
14 changes: 8 additions & 6 deletions src/windows/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::traits::*;
use std::collections::HashMap;
use std::path::PathBuf;
use winreg::enums::*;
use winreg::RegKey;
use wmi::{COMLibrary, Variant, WMIConnection};
Expand Down Expand Up @@ -411,13 +412,14 @@ impl WindowsPackageReadout {
}

fn count_scoop() -> Option<usize> {
if let Ok(path) = which::which("scoop") {
if let Ok(dir) = path.join("../../apps").read_dir() {
return Some(dir.count() - 1); // One entry belongs to scoop itself
}
let scoop = match std::env::var("SCOOP") {
Ok(scoop_var) => PathBuf::from(scoop_var),
_ => home::home_dir().unwrap().join("scoop"),
};
match scoop.join("apps").read_dir() {
Ok(dir) => Some(dir.count() - 1), // One entry belongs to scoop itself
_ => None,
}

None
}
}

Expand Down