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(
stack.push_back(glob_result);
while let Some(glob_result) = stack.pop_back() {
// Process direct results (files and directories at this level).
for entry in glob_result.results.values() {
let (DirectoryEntry::File(file_path) | DirectoryEntry::Symlink(file_path)) = entry
else {
for (entry, realpath) in glob_result.results.values() {
let (DirectoryEntry::File(_) | DirectoryEntry::Symlink(_)) = entry else {
continue;
};
// ReadGlobResult paths are logical by contract. Resolve each match here so the NFT
// includes both the physical file and every symlink needed to reach it.
let realpath = file_path.realpath_with_links().await?;
let realpath = realpath.await?;
result.extend(realpath.symlinks.iter().cloned());
if let Ok(resolved_path) = &realpath.path_result
&& matches!(*resolved_path.get_type().await?, FileSystemEntryType::File)
......
......@@ -72,8 +72,10 @@ async fn print_hash(dir_hash: Vc<RcStr>) -> Result<()> {
async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> {
let result = result.await?;
let mut hashes = BTreeMap::new();
for (name, entry) in result.results.iter() {
if let DirectoryEntry::File(path) = entry {
for (name, (entry, realpath)) in result.results.iter() {
if matches!(entry, DirectoryEntry::File(_))
&& let Ok(path) = &realpath.await?.path_result
{
hashes.insert(name, hash_file(path.clone()).owned().await?);
}
}
......@@ -98,9 +100,6 @@ async fn hash_glob_result(result: Vc<ReadGlobResult>) -> Result<Vc<RcStr>> {
#[turbo_tasks::function]
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?;
Ok(match &*content {
FileContent::Content(file) => hash_content(&mut file.read()),
......
......@@ -356,7 +356,7 @@ async fn flatten_read_glob(result: &ReadGlobResult) -> Result<Vec<(RcStr, FileSy
prefix: &str,
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() {
segment.to_string()
} 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