Skip to content

Commit

Permalink
fix unused import warning on Windows
Browse files Browse the repository at this point in the history
Summary:
# This diff

Makes some imports unix-only so that we can avoid some warnings during build time on Windows.

# Context

in_the_context

Reviewed By: muirdm

Differential Revision: D68838999

fbshipit-source-id: 620d5a0967ce681f945594f4b8384e1a2bb4cee9
  • Loading branch information
MichaelCuevas authored and facebook-github-bot committed Feb 1, 2025
1 parent 39a650c commit 27610e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions eden/scm/lib/util/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//! Path-related utilities.
use std::borrow::Cow;
use std::collections::HashSet;
use std::env;
use std::ffi::OsStr;
use std::fs;
Expand All @@ -22,8 +21,6 @@ use std::path::Component;
use std::path::Path;
use std::path::PathBuf;

use anyhow::bail;
use anyhow::Context;
use fn_error_context::context;

use crate::errors::IOContext;
Expand Down Expand Up @@ -357,6 +354,8 @@ fn add_stat_context<T, E: Into<anyhow::Error>>(
) -> anyhow::Result<T, anyhow::Error> {
use std::os::unix::fs::MetadataExt;

use anyhow::Context;

let res = res.map_err(Into::into);

if let Some(path) = path {
Expand All @@ -381,6 +380,10 @@ fn add_stat_context<T, E: Into<anyhow::Error>>(
/// Propagates unexpected errors like permission errors.
#[cfg(unix)]
fn resolve_symlinks(path: &Path) -> anyhow::Result<PathBuf> {
use std::collections::HashSet;

use anyhow::bail;
use anyhow::Context;
fn inner(path: PathBuf, seen: &mut HashSet<PathBuf>) -> anyhow::Result<PathBuf> {
if seen.contains(&path) {
bail!("symlink cycle containing {:?}", path);
Expand Down Expand Up @@ -420,6 +423,7 @@ fn resolve_symlinks(path: &Path) -> anyhow::Result<PathBuf> {
#[context("creating dir {:?} with mode 0o{:o}", path, mode)]
fn create_dir_with_mode(path: &Path, mode: u32) -> anyhow::Result<()> {
use anyhow::anyhow;
use anyhow::Context;

let path = resolve_symlinks(path)?;

Expand Down

0 comments on commit 27610e4

Please sign in to comment.