Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 11, 2024
1 parent 9a49cda commit d2c29e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/rattler_menuinst/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use fs_err as fs;

mod create_shortcut;
mod knownfolders;
mod registry;
mod lex;
mod registry;

pub struct Directories {
start_menu: PathBuf,
Expand Down
25 changes: 15 additions & 10 deletions crates/rattler_menuinst/src/windows/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ pub fn register_file_extension(
Ok(())
}

pub fn unregister_file_extension(extension: &str, identifier: &str, mode: &str) -> Result<(), std::io::Error> {
pub fn unregister_file_extension(
extension: &str,
identifier: &str,
mode: &str,
) -> Result<(), std::io::Error> {
let hkey = if mode == "system" {
HKEY_LOCAL_MACHINE
} else {
Expand All @@ -67,7 +71,8 @@ pub fn unregister_file_extension(extension: &str, identifier: &str, mode: &str)
if key.get_value::<String, _>(identifier).is_err() {
tracing::debug!(
"Handler '{}' is not associated with extension '{}'",
identifier, extension
identifier,
extension
);
} else {
key.delete_value(identifier)?;
Expand Down Expand Up @@ -114,7 +119,11 @@ pub fn register_url_protocol(
Ok(())
}

pub fn unregister_url_protocol(protocol: &str, identifier: Option<&str>, mode: &str) -> Result<(), std::io::Error> {
pub fn unregister_url_protocol(
protocol: &str,
identifier: Option<&str>,
mode: &str,
) -> Result<(), std::io::Error> {
let key = if mode == "system" {
RegKey::predef(HKEY_CLASSES_ROOT)
} else {
Expand All @@ -139,7 +148,6 @@ pub fn unregister_url_protocol(protocol: &str, identifier: Option<&str>, mode: &
Ok(())
}


#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -167,8 +175,7 @@ mod tests {
register_file_extension(extension, identifier, command, None, mode)?;

// Verify registration
let classes = RegKey::predef(HKEY_CURRENT_USER)
.open_subkey("Software\\Classes")?;
let classes = RegKey::predef(HKEY_CURRENT_USER).open_subkey("Software\\Classes")?;

let ext_key = classes.open_subkey(&format!("{}\\OpenWithProgids", extension))?;
assert!(ext_key.get_value::<String, _>(identifier).is_ok());
Expand All @@ -194,8 +201,7 @@ mod tests {
register_file_extension(extension, identifier, command, Some(icon), mode)?;

// Verify icon
let classes = RegKey::predef(HKEY_CURRENT_USER)
.open_subkey("Software\\Classes")?;
let classes = RegKey::predef(HKEY_CURRENT_USER).open_subkey("Software\\Classes")?;
let icon_key = classes.open_subkey(identifier)?;
let icon_value: String = icon_key.get_value("DefaultIcon")?;
assert_eq!(icon_value, icon);
Expand Down Expand Up @@ -269,8 +275,7 @@ mod tests {
unregister_url_protocol(protocol, identifier, mode)?;

// Verify removal
let key = RegKey::predef(HKEY_CURRENT_USER)
.open_subkey("Software\\Classes")?;
let key = RegKey::predef(HKEY_CURRENT_USER).open_subkey("Software\\Classes")?;
assert!(key.open_subkey(protocol).is_err());

Ok(())
Expand Down

0 comments on commit d2c29e6

Please sign in to comment.