Skip to content

Commit

Permalink
Fix Windows not copying globs or directories
Browse files Browse the repository at this point in the history
Signed-off-by: itowlson <[email protected]>
  • Loading branch information
itowlson committed Dec 12, 2023
1 parent de7d847 commit 9ad44b9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/loader/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ impl LocalLoader {
files_mount_strategy: FilesMountStrategy,
cache_root: Option<PathBuf>,
) -> Result<Self> {
let app_root = app_root
.canonicalize()
let app_root = safe_canonicalize(app_root)
.with_context(|| format!("Invalid manifest dir `{}`", app_root.display()))?;
Ok(Self {
app_root,
Expand Down Expand Up @@ -390,6 +389,20 @@ impl LocalLoader {
}
}

/// This canonicalizes the path in a way that works with globs. On non-Windows
/// platforms, we can use Path::canonicalize, but on Windows platforms this
/// expands to a UNC path, and the glob library does not work with UNC paths.
#[cfg(not(windows))]
fn safe_canonicalize(path: &Path) -> std::io::Result<PathBuf> {
path.canonicalize()
}

#[cfg(windows)]
fn safe_canonicalize(path: &Path) -> std::io::Result<PathBuf> {
use path_absolutize::Absolutize;
Ok(path.absolutize()?.into_owned())
}

fn locked_metadata(
details: v2::AppDetails,
trigger_types: impl Iterator<Item = String>,
Expand Down

0 comments on commit 9ad44b9

Please sign in to comment.