refactor: use async version of Path::canonicalize

This commit is contained in:
daimond113 2025-04-26 23:53:51 +02:00
parent 5c74a3762b
commit 91229d92be
No known key found for this signature in database
GPG key ID: 640DC95EC1190354
3 changed files with 15 additions and 16 deletions

View file

@ -1,4 +1,5 @@
avoid-breaking-exported-api = false avoid-breaking-exported-api = false
disallowed-methods = [ disallowed-methods = [
"std::path::Path::exists" "std::path::Path::exists",
"std::path::Path::canonicalize",
] ]

View file

@ -193,9 +193,8 @@ impl PublishCommand {
} }
} }
let canonical_package_dir = project let canonical_package_dir = fs::canonicalize(project.package_dir())
.package_dir() .await
.canonicalize()
.context("failed to canonicalize package directory")?; .context("failed to canonicalize package directory")?;
let mut archive = tokio_tar::Builder::new( let mut archive = tokio_tar::Builder::new(
@ -308,8 +307,8 @@ info: otherwise, the file was deemed unnecessary, if you don't understand why, p
} }
}; };
let export_path = export_path let export_path = fs::canonicalize(export_path)
.canonicalize() .await
.with_context(|| format!("failed to canonicalize {name}"))?; .with_context(|| format!("failed to canonicalize {name}"))?;
self.validate_luau_file(&format!("file at {name}"), &contents)?; self.validate_luau_file(&format!("file at {name}"), &contents)?;
@ -385,8 +384,8 @@ info: otherwise, the file was deemed unnecessary, if you don't understand why, p
} }
}; };
let script_path = script_path let script_path = fs::canonicalize(script_path)
.canonicalize() .await
.with_context(|| format!("failed to canonicalize script {name}"))?; .with_context(|| format!("failed to canonicalize script {name}"))?;
self.validate_luau_file(&format!("the `{name}` script"), &contents)?; self.validate_luau_file(&format!("the `{name}` script"), &contents)?;

View file

@ -188,14 +188,13 @@ impl RunCommand {
}; };
let members = members let members = members
.map(|res| { .then(|res| async {
res.map_err(anyhow::Error::from)? fs::canonicalize(res.map_err(anyhow::Error::from)?.0)
.0 .await
.canonicalize()
.map_err(anyhow::Error::from) .map_err(anyhow::Error::from)
}) })
.chain(futures::stream::once(async { .chain(futures::stream::once(async {
workspace_dir.canonicalize().map_err(Into::into) fs::canonicalize(workspace_dir).await.map_err(Into::into)
})) }))
.try_collect::<HashSet<_>>() .try_collect::<HashSet<_>>()
.await .await
@ -204,8 +203,8 @@ impl RunCommand {
let root = 'finder: { let root = 'finder: {
let mut current_path = path.clone(); let mut current_path = path.clone();
loop { loop {
let canonical_path = current_path let canonical_path = fs::canonicalize(&current_path)
.canonicalize() .await
.context("failed to canonicalize parent")?; .context("failed to canonicalize parent")?;
if members.contains(&canonical_path) if members.contains(&canonical_path)