mirror of
https://github.com/Zenithsiz/zbuild.git
synced 2026-02-03 22:23:53 +00:00
File metadata is now checked without following symlinks.
This commit is contained in:
parent
7b859c7eab
commit
6e224e969a
@ -234,7 +234,7 @@ impl<'s> Builder<'s> {
|
||||
// Get the rule for the target
|
||||
let Some((rule, target_rule)) = self.target_rule(&target, rules)? else {
|
||||
match target {
|
||||
Target::File { ref file, .. } => match fs::metadata(&**file).await {
|
||||
Target::File { ref file, .. } => match fs::symlink_metadata(&**file).await {
|
||||
Ok(metadata) => {
|
||||
let build_time = metadata.modified().map_err(AppError::get_file_modified_time(&**file))?;
|
||||
tracing::trace!(?target, ?build_time, "Found target file");
|
||||
@ -370,7 +370,7 @@ impl<'s> Builder<'s> {
|
||||
is_deps_file,
|
||||
is_output: false,
|
||||
is_optional,
|
||||
exists: util::fs_try_exists(&**file)
|
||||
exists: util::fs_try_exists_symlink(&**file)
|
||||
.await
|
||||
.map_err(AppError::check_file_exists(&**file))?,
|
||||
}),
|
||||
@ -405,7 +405,7 @@ impl<'s> Builder<'s> {
|
||||
is_deps_file: true,
|
||||
is_output: true,
|
||||
is_optional: false,
|
||||
exists: util::fs_try_exists(&**file)
|
||||
exists: util::fs_try_exists_symlink(&**file)
|
||||
.await
|
||||
.map_err(AppError::check_file_exists(&**file))?,
|
||||
})),
|
||||
@ -804,7 +804,7 @@ async fn rule_last_build_time<'s>(rule: &Rule<'s, CowStr<'s>>) -> Result<Option<
|
||||
let file = match item {
|
||||
OutItem::File { file, .. } => file,
|
||||
};
|
||||
let metadata = fs::metadata(&**file)
|
||||
let metadata = fs::symlink_metadata(&**file)
|
||||
.await
|
||||
.map_err(AppError::read_file_metadata(&**file))?;
|
||||
let modified_time = metadata.modified().map_err(AppError::get_file_modified_time(&**file))?;
|
||||
|
||||
@ -218,7 +218,7 @@ decl_error! {
|
||||
)
|
||||
)]
|
||||
#[source(Some(source))]
|
||||
#[fmt("Unable to read file metadata {file_path:?}")]
|
||||
#[fmt("Unable to read file metadata (not following symlinks) {file_path:?}")]
|
||||
ReadFileMetadata {
|
||||
/// Underlying error
|
||||
source: io::Error,
|
||||
|
||||
@ -206,7 +206,7 @@ async fn find_zbuild() -> Result<PathBuf, AppError> {
|
||||
|
||||
loop {
|
||||
let zbuild_path = cur_path.join("zbuild.yaml");
|
||||
match util::fs_try_exists(&zbuild_path)
|
||||
match util::fs_try_exists_symlink(&zbuild_path)
|
||||
.await
|
||||
.map_err(AppError::check_file_exists(&zbuild_path))?
|
||||
{
|
||||
|
||||
@ -30,9 +30,9 @@ pub macro chain {
|
||||
},
|
||||
}
|
||||
|
||||
/// Async `std::fs_try_exists`
|
||||
pub async fn fs_try_exists(path: impl AsRef<Path> + Send) -> Result<bool, io::Error> {
|
||||
match fs::metadata(path).await {
|
||||
/// Async `std::fs_try_exists` using [`symlink_metadata`](fs::symlink_metadata).
|
||||
pub async fn fs_try_exists_symlink(path: impl AsRef<Path> + Send) -> Result<bool, io::Error> {
|
||||
match fs::symlink_metadata(path).await {
|
||||
Ok(_) => Ok(true),
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(false),
|
||||
Err(err) => Err(err),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user