Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows not copying globs or directories #2161

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
itowlson marked this conversation as resolved.
Show resolved Hide resolved
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