Skip to content

Commit

Permalink
allow to resolve symlinks on DirectoryEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 26, 2024
1 parent 2422858 commit 2297692
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,24 @@ pub enum DirectoryEntry {
Error,
}

/// Handles the `DirectoryEntry::Symlink` variant by checking the symlink target
/// type and replacing it with `DirectoryEntry::File` or
/// `DirectoryEntry::Directory`.
impl DirectoryEntry {
pub async fn resolve_symlink(self) -> Result<Self> {
if let DirectoryEntry::Symlink(symlink) = self {
let real_path = symlink.realpath().resolve().await?;
match *real_path.get_type().await? {
FileSystemEntryType::Directory => Ok(DirectoryEntry::Directory(real_path)),
FileSystemEntryType::File => Ok(DirectoryEntry::File(real_path)),
_ => Ok(self),
}
} else {
Ok(self)
}
}
}

#[turbo_tasks::value]
#[derive(Hash, Clone, Copy, Debug)]
pub enum FileSystemEntryType {
Expand Down

0 comments on commit 2297692

Please sign in to comment.