Unverified Commit 1300acfe authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: rename some fields in fs (#83808)

Apply suggestions from https://github.com/vercel/next.js/pull/83805
parent 8b17a636
...@@ -1387,7 +1387,7 @@ impl FileSystemPath { ...@@ -1387,7 +1387,7 @@ impl FileSystemPath {
// is invalid. // is invalid.
pub async fn realpath(&self) -> Result<FileSystemPath> { pub async fn realpath(&self) -> Result<FileSystemPath> {
let result = &(*self.realpath_with_links().await?); let result = &(*self.realpath_with_links().await?);
match &result.path_or_error { match &result.path_result {
Ok(path) => Ok(path.clone()), Ok(path) => Ok(path.clone()),
Err(error) => Err(anyhow::anyhow!(error.as_error_message(self, result))), Err(error) => Err(anyhow::anyhow!(error.as_error_message(self, result))),
} }
...@@ -1449,7 +1449,7 @@ impl ValueToString for FileSystemPath { ...@@ -1449,7 +1449,7 @@ impl ValueToString for FileSystemPath {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub struct RealPathResult { pub struct RealPathResult {
pub path_or_error: Result<FileSystemPath, RealPathResultError>, pub path_result: Result<FileSystemPath, RealPathResultError>,
pub symlinks: Vec<FileSystemPath>, pub symlinks: Vec<FileSystemPath>,
} }
...@@ -2121,7 +2121,7 @@ impl DirectoryEntry { ...@@ -2121,7 +2121,7 @@ impl DirectoryEntry {
pub async fn resolve_symlink(self) -> Result<Self> { pub async fn resolve_symlink(self) -> Result<Self> {
if let DirectoryEntry::Symlink(symlink) = &self { if let DirectoryEntry::Symlink(symlink) = &self {
let result = &*symlink.realpath_with_links().await?; let result = &*symlink.realpath_with_links().await?;
let real_path = match &result.path_or_error { let real_path = match &result.path_result {
Ok(path) => path, Ok(path) => path,
Err(error) => { Err(error) => {
return Ok(DirectoryEntry::Error( return Ok(DirectoryEntry::Error(
...@@ -2136,9 +2136,9 @@ impl DirectoryEntry { ...@@ -2136,9 +2136,9 @@ impl DirectoryEntry {
FileSystemEntryType::NotFound => DirectoryEntry::Error( FileSystemEntryType::NotFound => DirectoryEntry::Error(
format!("Symlink {symlink} points at {real_path} which does not exist").into(), format!("Symlink {symlink} points at {real_path} which does not exist").into(),
), ),
// This is caused by eventual consistency
FileSystemEntryType::Symlink => bail!( FileSystemEntryType::Symlink => bail!(
"Symlink {symlink} points at a symlink but realpath_with_links returned a \ "Symlink {symlink} points at a symlink but realpath_with_links returned a path"
path, this is caused by eventual consistency."
), ),
_ => self, _ => self,
}) })
...@@ -2376,7 +2376,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>> ...@@ -2376,7 +2376,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>>
if current_path.is_root() { if current_path.is_root() {
// fast path // fast path
return Ok(RealPathResult { return Ok(RealPathResult {
path_or_error: Ok(current_path), path_result: Ok(current_path),
symlinks: symlinks.into_iter().collect(), symlinks: symlinks.into_iter().collect(),
} }
.cell()); .cell());
...@@ -2395,7 +2395,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>> ...@@ -2395,7 +2395,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>>
.rsplit_once('/') .rsplit_once('/')
.map_or(current_path.path.as_str(), |(_, name)| name); .map_or(current_path.path.as_str(), |(_, name)| name);
symlinks.extend(parent_result.symlinks); symlinks.extend(parent_result.symlinks);
let parent_path = match parent_result.path_or_error { let parent_path = match parent_result.path_result {
Ok(path) => { Ok(path) => {
if path != parent { if path != parent {
current_path = path.join(basename)?; current_path = path.join(basename)?;
...@@ -2415,7 +2415,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>> ...@@ -2415,7 +2415,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>>
FileSystemEntryType::Symlink FileSystemEntryType::Symlink
) { ) {
return Ok(RealPathResult { return Ok(RealPathResult {
path_or_error: Ok(current_path), path_result: Ok(current_path),
symlinks: symlinks.into_iter().collect(), // convert set to vec symlinks: symlinks.into_iter().collect(), // convert set to vec
} }
.cell()); .cell());
...@@ -2450,7 +2450,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>> ...@@ -2450,7 +2450,7 @@ async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>>
// Returning the followed symlinks is still important, even if there is an error! Otherwise // Returning the followed symlinks is still important, even if there is an error! Otherwise
// we may never notice if the symlink loop is fixed. // we may never notice if the symlink loop is fixed.
Ok(RealPathResult { Ok(RealPathResult {
path_or_error: Err(error), path_result: Err(error),
symlinks: symlinks.into_iter().collect(), symlinks: symlinks.into_iter().collect(),
} }
.cell()) .cell())
......
...@@ -121,7 +121,7 @@ async fn dir_references(package_dir: FileSystemPath) -> Result<Vc<ModuleReferenc ...@@ -121,7 +121,7 @@ async fn dir_references(package_dir: FileSystemPath) -> Result<Vc<ModuleReferenc
PatternMatch::File(_, file) => { PatternMatch::File(_, file) => {
let realpath = file.realpath_with_links().await?; let realpath = file.realpath_with_links().await?;
results.extend(realpath.symlinks.iter().cloned()); results.extend(realpath.symlinks.iter().cloned());
match &realpath.path_or_error { match &realpath.path_result {
Ok(path) => { Ok(path) => {
results.insert(path.clone()); results.insert(path.clone());
} }
......
...@@ -1185,7 +1185,7 @@ async fn realpath( ...@@ -1185,7 +1185,7 @@ async fn realpath(
.try_join() .try_join()
.await?, .await?,
); );
match &result.path_or_error { match &result.path_result {
Ok(path) => Ok(path.clone()), Ok(path) => Ok(path.clone()),
Err(e) => bail!(e.as_error_message(fs_path, &result)), Err(e) => bail!(e.as_error_message(fs_path, &result)),
} }
...@@ -1520,7 +1520,7 @@ pub async fn resolve_raw( ...@@ -1520,7 +1520,7 @@ pub async fn resolve_raw(
) -> Result<Vc<ResolveResult>> { ) -> Result<Vc<ResolveResult>> {
async fn to_result(request: RcStr, path: FileSystemPath) -> Result<Vc<ResolveResult>> { async fn to_result(request: RcStr, path: FileSystemPath) -> Result<Vc<ResolveResult>> {
let result = &*path.realpath_with_links().await?; let result = &*path.realpath_with_links().await?;
let path = match &result.path_or_error { let path = match &result.path_result {
Ok(path) => path, Ok(path) => path,
Err(e) => bail!(e.as_error_message(&path, result)), Err(e) => bail!(e.as_error_message(&path, result)),
}; };
...@@ -2873,7 +2873,7 @@ async fn resolved( ...@@ -2873,7 +2873,7 @@ async fn resolved(
fragment: RcStr, fragment: RcStr,
) -> Result<Vc<ResolveResult>> { ) -> Result<Vc<ResolveResult>> {
let result = &*fs_path.realpath_with_links().await?; let result = &*fs_path.realpath_with_links().await?;
let path = match &result.path_or_error { let path = match &result.path_result {
Ok(path) => path, Ok(path) => path,
Err(e) => bail!(e.as_error_message(&fs_path, result)), Err(e) => bail!(e.as_error_message(&fs_path, result)),
}; };
......
...@@ -124,7 +124,7 @@ async fn resolve_reference_from_dir( ...@@ -124,7 +124,7 @@ async fn resolve_reference_from_dir(
FileSource::new(symlink.clone()).to_resolved().await?, FileSource::new(symlink.clone()).to_resolved().await?,
)); ));
} }
let path: FileSystemPath = match &realpath.path_or_error { let path: FileSystemPath = match &realpath.path_result {
Ok(path) => path.clone(), Ok(path) => path.clone(),
Err(e) => bail!(e.as_error_message(file, &realpath)), Err(e) => bail!(e.as_error_message(file, &realpath)),
}; };
......
...@@ -185,7 +185,7 @@ pub async fn resolve_node_pre_gyp_files( ...@@ -185,7 +185,7 @@ pub async fn resolve_node_pre_gyp_files(
} }
sources.insert( sources.insert(
format!("deps/lib/{key}").into(), format!("deps/lib/{key}").into(),
Vc::upcast(FileSource::new(match &realpath_with_links.path_or_error { Vc::upcast(FileSource::new(match &realpath_with_links.path_result {
Ok(path) => path.clone(), Ok(path) => path.clone(),
Err(e) => bail!(e.as_error_message(dylib, &realpath_with_links)), Err(e) => bail!(e.as_error_message(dylib, &realpath_with_links)),
})), })),
......
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