Skip to content

Commit 86b159d

Browse files
Fix PathBuf initialization in command_discovery.rs
- Change path and directory from String conversion to PathBuf in load_resource_manifest - Change path and directory from String conversion to PathBuf in load_extension_manifest - Fix canonicalize_which call in verify_executable to pass &Path instead of string reference Co-authored-by: adityapatwardhan <12820925+adityapatwardhan@users.noreply.github.com>
1 parent ec507b2 commit 86b159d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/dsc-lib/src/discovery/command_discovery.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,8 @@ fn load_resource_manifest(path: &Path, manifest: &ResourceManifest) -> Result<Ds
751751
description: manifest.description.clone(),
752752
version: manifest.version.clone(),
753753
capabilities,
754-
path: path.to_str().unwrap().to_string(),
755-
directory: path.parent().unwrap().to_str().unwrap().to_string(),
754+
path: path.to_path_buf(),
755+
directory: path.parent().unwrap().to_path_buf(),
756756
manifest: Some(serde_json::to_value(manifest)?),
757757
..Default::default()
758758
};
@@ -793,8 +793,8 @@ fn load_extension_manifest(path: &Path, manifest: &ExtensionManifest) -> Result<
793793
version: manifest.version.clone(),
794794
capabilities,
795795
import_file_extensions: import_extensions,
796-
path: path.to_str().unwrap().to_string(),
797-
directory: path.parent().unwrap().to_str().unwrap().to_string(),
796+
path: path.to_path_buf(),
797+
directory: path.parent().unwrap().to_path_buf(),
798798
manifest: serde_json::to_value(manifest)?,
799799
..Default::default()
800800
};
@@ -803,7 +803,7 @@ fn load_extension_manifest(path: &Path, manifest: &ExtensionManifest) -> Result<
803803
}
804804

805805
fn verify_executable(resource: &str, operation: &str, executable: &str, directory: &Path) {
806-
if canonicalize_which(executable, Some(directory.to_string_lossy().as_ref())).is_err() {
806+
if canonicalize_which(executable, Some(directory)).is_err() {
807807
info!("{}", t!("discovery.commandDiscovery.executableNotFound", resource = resource, operation = operation, executable = executable));
808808
}
809809
}

0 commit comments

Comments
 (0)