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
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
.package_dir()
.canonicalize()
let canonical_package_dir = fs::canonicalize(project.package_dir())
.await
.context("failed to canonicalize package directory")?;
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
.canonicalize()
let export_path = fs::canonicalize(export_path)
.await
.with_context(|| format!("failed to canonicalize {name}"))?;
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
.canonicalize()
let script_path = fs::canonicalize(script_path)
.await
.with_context(|| format!("failed to canonicalize script {name}"))?;
self.validate_luau_file(&format!("the `{name}` script"), &contents)?;

View file

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