Skip to content

Commit

Permalink
Fix path checking
Browse files Browse the repository at this point in the history
  • Loading branch information
sop committed Sep 23, 2019
1 parent e317624 commit 065dae0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,10 @@ pub fn get_handler_executable_path(ext: &str) -> Result<PathBuf, Error> {
/// Returns an error if extension is not registered for WSLScript, or some
/// error occurs.
pub fn is_registered_for_current_executable(ext: &str) -> Result<bool, Error> {
let registered_exe = get_handler_executable_path(ext)?
.canonicalize()
.map_err(|_| ErrorKind::InvalidPathError)?;
let current_exe = std::env::current_exe()
.map_err(|_| ErrorKind::InvalidPathError)?
.canonicalize()
.map_err(|_| ErrorKind::InvalidPathError)?;
let registered_exe = get_handler_executable_path(ext)?;
let registered_exe = registered_exe.canonicalize().unwrap_or(registered_exe);
let current_exe = std::env::current_exe()?;
let current_exe = current_exe.canonicalize().unwrap_or(current_exe);
if current_exe == registered_exe {
return Ok(true);
}
Expand Down

0 comments on commit 065dae0

Please sign in to comment.