Skip to content

Commit

Permalink
Reverted rename
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaslyang authored and nicholaslyang committed Oct 23, 2023
1 parent 8348a64 commit 1c9a12e
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 101 deletions.
8 changes: 4 additions & 4 deletions crates/turborepo-cache/src/cache_archive/restore_symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::backtrace::Backtrace;

use camino::Utf8Path;
use turbopath::{
AbsoluteSystemPath, AbsoluteSystemPathBuf, AnchoredSystemPath, AnchoredSystemPathBuf, Error,
UnknownPathType,
AbsoluteSystemPath, AbsoluteSystemPathBuf, AnchoredSystemPath, AnchoredSystemPathBuf,
PathError, UnknownPathType,
};

use crate::{cache_archive::restore_directory::CachedDirTree, CacheError};
Expand Down Expand Up @@ -60,7 +60,7 @@ fn actually_restore_symlink<'a>(
let link_name = header.link_name()?.expect("have linkname");
let symlink_to = link_name.to_str().ok_or_else(|| {
CacheError::PathError(
Error::InvalidUnicode(link_name.to_string_lossy().to_string()),
PathError::InvalidUnicode(link_name.to_string_lossy().to_string()),
Backtrace::capture(),
)
})?;
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn canonicalize_linkname(
) -> Result<AbsoluteSystemPathBuf, CacheError> {
let linkname = linkname.try_into().map_err(|_| {
CacheError::PathError(
Error::InvalidUnicode(linkname.to_string_lossy().to_string()),
PathError::InvalidUnicode(linkname.to_string_lossy().to_string()),
Backtrace::capture(),
)
})?;
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum CacheError {
#[error("invalid duration")]
InvalidDuration(#[backtrace] Backtrace),
#[error("Invalid file path: {0}")]
PathError(#[from] turbopath::Error, #[backtrace] Backtrace),
PathError(#[from] turbopath::PathError, #[backtrace] Backtrace),
#[error("links in the cache are cyclic")]
CycleDetected(#[backtrace] Backtrace),
#[error("Invalid file path, link target does not exist: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{collections::HashMap, mem::ManuallyDrop};

use globwalk::globwalk;
pub use lockfile::{patches, subgraph, transitive_closure};
use turbopath::{AbsoluteSystemPathBuf, AnchoredSystemPathBuf, Error};
use turbopath::{AbsoluteSystemPathBuf, AnchoredSystemPathBuf, PathError};
use turborepo_env::EnvironmentVariableMap;

mod proto {
Expand Down Expand Up @@ -305,7 +305,7 @@ pub extern "C" fn get_hashes_for_files(buffer: Buffer) -> Buffer {
.files
.iter()
.map(AnchoredSystemPathBuf::from_raw)
.collect::<Result<Vec<_>, Error>>()
.collect::<Result<Vec<_>, PathError>>()
{
Ok(files) => files,
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use walkdir::WalkDir;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Path(#[from] turbopath::Error),
Path(#[from] turbopath::PathError),
#[error(transparent)]
Io(#[from] io::Error),
#[error("error walking directory during recursive copy: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-globwalk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use itertools::Itertools;
use path_slash::PathExt;
use regex::Regex;
use tracing::{info_span, Span};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, Error};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, PathError};
use wax::{Any, BuildError, Glob, Pattern};

#[derive(Debug, PartialEq, Clone, Copy)]
Expand Down Expand Up @@ -56,7 +56,7 @@ pub enum WalkError {
#[error("walk error: {0}")]
WalkError(#[from] walkdir::Error),
#[error(transparent)]
Path(#[from] Error),
Path(#[from] PathError),
#[error(transparent)]
WaxWalk(#[from] wax::WalkError),
#[error("Internal error on glob {glob}: {error}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-globwatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ use tokio::sync::{
};
use tokio_stream::wrappers::UnboundedReceiverStream;
use tracing::{error, event, span, trace, warn, Level};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, Error};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, PathError};

/// WatchError wraps errors produced by GlobWatcher
#[derive(Debug, Error)]
pub enum WatchError {
// TODO: find a generic way to include the path in these errors
/// PathError wraps errors encountered dealing with paths while filewatching
#[error("Filewatching encountered a path error: {0}")]
PathError(#[from] Error),
PathError(#[from] PathError),
/// IO wraps IO errors encountered while attempting to watch the filesystem
#[error("Filewatching encountered an IO Error: {0}")]
IO(#[from] io::Error),
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Error {
#[error("{0}")]
Bin(#[from] bin::Error, #[backtrace] backtrace::Backtrace),
#[error(transparent)]
Path(#[from] turbopath::Error),
Path(#[from] turbopath::PathError),
#[error("at least one task must be specified")]
NoTasks(#[backtrace] backtrace::Backtrace),
#[error(transparent)]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum Error {
#[error("json error while pruning: {0}")]
Json(#[from] serde_json::Error),
#[error("path error while pruning: {0}")]
Path(#[from] turbopath::Error),
Path(#[from] turbopath::PathError),
#[error(transparent)]
PackageJson(#[from] turborepo_repository::package_json::Error),
#[error(transparent)]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub enum Error {
env_pipeline_delimiter: &'static str,
},
#[error(transparent)]
PathError(#[from] turbopath::Error),
PathError(#[from] turbopath::PathError),
#[error("\"{actual}\". Use \"{wanted}\" instead")]
UnnecessaryPackageTaskSyntax { actual: String, wanted: String },
#[error("You can only extend from the root workspace")]
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-lib/src/globwatcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use notify::{EventKind, RecommendedWatcher};
use thiserror::Error;
use tokio::time::timeout;
use tracing::{trace, warn};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, Error};
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, PathError};
use wax::{Glob as WaxGlob, Pattern};

// these aliases are for readability, but they're just strings. it may make
Expand Down Expand Up @@ -53,7 +53,7 @@ pub enum HashGlobSetupError {
#[error("failed to start tracking hash-globs {0}")]
WatchError(#[from] WatchError),
#[error("failed to calculate relative path for hash-glob watching ({1}): {0}")]
PathError(Error, AbsoluteSystemPathBuf),
PathError(PathError, AbsoluteSystemPathBuf),
}

impl HashGlobWatcher<RecommendedWatcher> {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/package_graph/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum Error {
existing_path: String,
},
#[error("path error: {0}")]
TurboPath(#[from] turbopath::Error),
TurboPath(#[from] turbopath::PathError),
#[error("unable to parse workspace package.json: {0}")]
PackageJson(#[from] turborepo_repository::package_json::Error),
#[error("package.json must have a name field:\n{0}")]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/task_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum Error {
#[error(transparent)]
Regex(#[from] regex::Error),
#[error(transparent)]
Path(#[from] turbopath::Error),
Path(#[from] turbopath::PathError),
}

impl TaskHashable<'_> {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lockfiles/src/berry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ impl Lockfile for BerryLockfile {
.filter_map(|patch| patch.patch_file())
.filter(|path| !Locator::is_patch_builtin(path))
.map(|s| RelativeUnixPathBuf::new(s.to_string()))
.collect::<Result<Vec<_>, turbopath::Error>>()?;
.collect::<Result<Vec<_>, turbopath::PathError>>()?;
patches.sort();
Ok(patches)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lockfiles/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ pub enum Error {
#[error(transparent)]
Berry(#[from] crate::berry::Error),
#[error("lockfile contains invalid path: {0}")]
Path(#[from] turbopath::Error),
Path(#[from] turbopath::PathError),
}
2 changes: 1 addition & 1 deletion crates/turborepo-lockfiles/src/pnpm/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl crate::Lockfile for PnpmLockfile {
.iter()
.flatten()
.map(|(_, patch)| RelativeUnixPathBuf::new(&patch.path))
.collect::<Result<Vec<_>, turbopath::Error>>()?;
.collect::<Result<Vec<_>, turbopath::PathError>>()?;
patches.sort();
Ok(patches)
}
Expand Down
30 changes: 15 additions & 15 deletions crates/turborepo-paths/src/absolute_system_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use path_clean::PathClean;
use wax::CandidatePath;

use crate::{
AbsoluteSystemPathBuf, AnchoredSystemPath, AnchoredSystemPathBuf, Error, RelativeUnixPath,
AbsoluteSystemPathBuf, AnchoredSystemPath, AnchoredSystemPathBuf, PathError, RelativeUnixPath,
};

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -89,19 +89,19 @@ impl AbsoluteSystemPath {
/// assert!(AbsoluteSystemPath::new("/foo/bar").is_err());
/// }
/// ```
pub fn new<P: AsRef<str> + ?Sized>(value: &P) -> Result<&Self, Error> {
pub fn new<P: AsRef<str> + ?Sized>(value: &P) -> Result<&Self, PathError> {
let path: &Utf8Path = value.as_ref().into();
Self::from_utf8_path(path)
}

pub fn from_std_path(path: &Path) -> Result<&Self, Error> {
pub fn from_std_path(path: &Path) -> Result<&Self, PathError> {
let path: &Utf8Path = path.try_into()?;
Self::from_utf8_path(path)
}

fn from_utf8_path(path: &Utf8Path) -> Result<&Self, Error> {
fn from_utf8_path(path: &Utf8Path) -> Result<&Self, PathError> {
if path.is_relative() {
return Err(Error::NotAbsolute(path.to_string()));
return Err(PathError::NotAbsolute(path.to_string()));
}
Ok(Self::new_unchecked(path))
}
Expand Down Expand Up @@ -221,14 +221,14 @@ impl AbsoluteSystemPath {
pub fn join_unix_path(
&self,
unix_path: impl AsRef<RelativeUnixPath>,
) -> Result<AbsoluteSystemPathBuf, Error> {
) -> Result<AbsoluteSystemPathBuf, PathError> {
let tail = unix_path.as_ref().to_system_path_buf();
Ok(AbsoluteSystemPathBuf(
self.0.join(tail).as_std_path().clean().try_into()?,
))
}

pub fn anchor(&self, path: &AbsoluteSystemPath) -> Result<AnchoredSystemPathBuf, Error> {
pub fn anchor(&self, path: &AbsoluteSystemPath) -> Result<AnchoredSystemPathBuf, PathError> {
AnchoredSystemPathBuf::new(self, path)
}

Expand All @@ -240,13 +240,13 @@ impl AbsoluteSystemPath {
}
}

pub fn symlink_to_file<P: AsRef<str>>(&self, to: P) -> Result<(), Error> {
pub fn symlink_to_file<P: AsRef<str>>(&self, to: P) -> Result<(), PathError> {
let target = to.as_ref();
symlink_file(target, &self.0)?;
Ok(())
}

pub fn symlink_to_dir<P: AsRef<str>>(&self, to: P) -> Result<(), Error> {
pub fn symlink_to_dir<P: AsRef<str>>(&self, to: P) -> Result<(), PathError> {
let target = to.as_ref();
symlink_dir(target, &self.0)?;

Expand All @@ -258,31 +258,31 @@ impl AbsoluteSystemPath {
AbsoluteSystemPathBuf(path)
}

pub fn clean(&self) -> Result<AbsoluteSystemPathBuf, Error> {
pub fn clean(&self) -> Result<AbsoluteSystemPathBuf, PathError> {
let cleaned_path = self
.0
.as_std_path()
.clean()
.try_into()
.map_err(|_| Error::InvalidUnicode(self.0.as_str().to_owned()))?;
.map_err(|_| PathError::InvalidUnicode(self.0.as_str().to_owned()))?;

Ok(AbsoluteSystemPathBuf(cleaned_path))
}

pub fn to_realpath(&self) -> Result<AbsoluteSystemPathBuf, Error> {
pub fn to_realpath(&self) -> Result<AbsoluteSystemPathBuf, PathError> {
let realpath = dunce::canonicalize(&self.0)?;
Ok(AbsoluteSystemPathBuf(Utf8PathBuf::try_from(realpath)?))
}

// note that this is *not* lstat. If this is a symlink, it
// will return metadata for the target.
pub fn stat(&self) -> Result<Metadata, Error> {
pub fn stat(&self) -> Result<Metadata, PathError> {
Ok(fs::metadata(&self.0)?)
}

// The equivalent of lstat. Returns the metadata for this file,
// even if it is a symlink
pub fn symlink_metadata(&self) -> Result<Metadata, Error> {
pub fn symlink_metadata(&self) -> Result<Metadata, PathError> {
Ok(fs::symlink_metadata(&self.0)?)
}

Expand Down Expand Up @@ -472,7 +472,7 @@ impl PartialEq<&AbsoluteSystemPath> for PathBuf {
}

impl<'a> TryFrom<&'a Path> for &'a AbsoluteSystemPath {
type Error = Error;
type Error = PathError;

fn try_from(value: &'a Path) -> Result<Self, Self::Error> {
AbsoluteSystemPath::from_std_path(value)
Expand Down

0 comments on commit 1c9a12e

Please sign in to comment.