Unverified Commit 09511c8a authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Pair glob entries with resolved paths

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 17a901a7
...@@ -200,15 +200,12 @@ async fn get_glob_includes( ...@@ -200,15 +200,12 @@ async fn get_glob_includes(
stack.push_back(glob_result); stack.push_back(glob_result);
while let Some(glob_result) = stack.pop_back() { while let Some(glob_result) = stack.pop_back() {
// Process direct results (files and directories at this level). // Process direct results (files and directories at this level).
for entry in glob_result.results.values() { for (entry, realpath) in glob_result.results.values() {
let (DirectoryEntry::File(file_path) | DirectoryEntry::Symlink(file_path)) = entry let (DirectoryEntry::File(_) | DirectoryEntry::Symlink(_)) = entry else {
else {
continue; continue;
}; };
// ReadGlobResult paths are logical by contract. Resolve each match here so the NFT let realpath = realpath.await?;
// includes both the physical file and every symlink needed to reach it.
let realpath = file_path.realpath_with_links().await?;
result.extend(realpath.symlinks.iter().cloned()); result.extend(realpath.symlinks.iter().cloned());
if let Ok(resolved_path) = &realpath.path_result if let Ok(resolved_path) = &realpath.path_result
&& matches!(*resolved_path.get_type().await?, FileSystemEntryType::File) && matches!(*resolved_path.get_type().await?, FileSystemEntryType::File)
......
...@@ -72,8 +72,10 @@ async fn print_hash(dir_hash: Vc<RcStr>) -> Result<()> { ...@@ -72,8 +72,10 @@ async fn print_hash(dir_hash: Vc<RcStr>) -> Result<()> {
async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> { async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> {
let result = result.await?; let result = result.await?;
let mut hashes = BTreeMap::new(); let mut hashes = BTreeMap::new();
for (name, entry) in result.results.iter() { for (name, (entry, realpath)) in result.results.iter() {
if let DirectoryEntry::File(path) = entry { if matches!(entry, DirectoryEntry::File(_))
&& let Ok(path) = &realpath.await?.path_result
{
hashes.insert(name, hash_file(path.clone()).owned().await?); hashes.insert(name, hash_file(path.clone()).owned().await?);
} }
} }
...@@ -98,9 +100,6 @@ async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> { ...@@ -98,9 +100,6 @@ async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn hash_file(file_path: FileSystemPath) -> Result<Vc<RcStr>> { async fn hash_file(file_path: FileSystemPath) -> Result<Vc<RcStr>> {
let Ok(file_path) = file_path.realpath().await? else {
return Ok(empty_string());
};
let content = file_path.read().await?; let content = file_path.read().await?;
Ok(match &*content { Ok(match &*content {
FileContent::Content(file) => hash_content(&mut file.read()), FileContent::Content(file) => hash_content(&mut file.read()),
......
...@@ -356,7 +356,7 @@ async fn flatten_read_glob(result: &ReadGlobResult) -> Result<Vec<(RcStr, FileSy ...@@ -356,7 +356,7 @@ async fn flatten_read_glob(result: &ReadGlobResult) -> Result<Vec<(RcStr, FileSy
prefix: &str, prefix: &str,
files: &mut Vec<(RcStr, FileSystemPath)>, files: &mut Vec<(RcStr, FileSystemPath)>,
) { ) {
for (segment, entry) in &node.results { for (segment, (entry, _realpath)) in &node.results {
let full_path = if prefix.is_empty() { let full_path = if prefix.is_empty() {
segment.to_string() segment.to_string()
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment