Skip to content

Commit

Permalink
Add tracing to non-linux builds
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jul 14, 2024
1 parent 95a2678 commit 02d0910
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions fuc_engine/src/ops/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ mod compat {

#[cfg(not(target_os = "linux"))]
mod compat {
use std::{borrow::Cow, fs, io, path::Path};
use std::{borrow::Cow, fmt::Debug, fs, io, path::Path};

use rayon::prelude::*;

Expand All @@ -623,6 +623,7 @@ mod compat {
}

impl DirectoryOp<(Cow<'_, Path>, Cow<'_, Path>)> for Impl {
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn run(&self, (from, to): (Cow<Path>, Cow<Path>)) -> Result<(), Error> {
copy_dir(
&from,
Expand All @@ -635,12 +636,14 @@ mod compat {
.map_io_err(|| format!("Failed to copy directory: {from:?}"))
}

#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn finish(self) -> Result<(), Error> {
Ok(())
}
}

fn copy_dir<P: AsRef<Path>, Q: AsRef<Path>>(
#[cfg_attr(feature = "tracing", tracing::instrument(level = "info"))]
fn copy_dir<P: AsRef<Path> + Debug, Q: AsRef<Path> + Debug>(
from: P,
to: Q,
#[cfg(unix)] follow_symlinks: bool,
Expand Down Expand Up @@ -698,7 +701,8 @@ mod compat {
}

#[cfg(unix)]
fn maybe_compute_root_to_inode<P: AsRef<Path>>(
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace"))]
fn maybe_compute_root_to_inode<P: AsRef<Path> + Debug>(
to: P,
root_to_inode: Option<u64>,
) -> Result<u64, io::Error> {
Expand Down
9 changes: 7 additions & 2 deletions fuc_engine/src/ops/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ mod compat {

#[cfg(all(not(target_os = "linux"), not(target_os = "windows")))]
mod compat {
use std::{borrow::Cow, fs, io, path::Path};
use std::{borrow::Cow, fmt::Debug, fs, io, path::Path};

use rayon::prelude::*;

Expand All @@ -450,16 +450,19 @@ mod compat {
}

impl DirectoryOp<Cow<'_, Path>> for Impl {
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn run(&self, dir: Cow<Path>) -> Result<(), Error> {
remove_dir_all(&dir).map_io_err(|| format!("Failed to delete directory: {dir:?}"))
}

#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn finish(self) -> Result<(), Error> {
Ok(())
}
}

fn remove_dir_all<P: AsRef<Path>>(path: P) -> Result<(), io::Error> {
#[cfg_attr(feature = "tracing", tracing::instrument(level = "info"))]
fn remove_dir_all<P: AsRef<Path> + Debug>(path: P) -> Result<(), io::Error> {
let path = path.as_ref();
path.read_dir()?
.par_bridge()
Expand Down Expand Up @@ -494,10 +497,12 @@ mod compat {
}

impl DirectoryOp<Cow<'_, Path>> for Impl {
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn run(&self, dir: Cow<Path>) -> Result<(), Error> {
remove_dir_all(&dir).map_io_err(|| format!("Failed to delete directory: {dir:?}"))
}

#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
fn finish(self) -> Result<(), Error> {
Ok(())
}
Expand Down

0 comments on commit 02d0910

Please sign in to comment.