Skip to content

Commit

Permalink
Avoid UNC paths for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-spiess committed Aug 5, 2024
1 parent 5e65427 commit caa00b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/oxide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ignore = "0.4.20"
lazy_static = "1.4.0"
glob-match = "0.2.1"
serial_test = "3.1.1"
dunce = "1.0.5"

[dev-dependencies]
tempfile = "3.5.0"
Expand Down
44 changes: 20 additions & 24 deletions crates/oxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use ignore::WalkBuilder;
use lazy_static::lazy_static;
use rayon::prelude::*;
use std::cmp::Ordering;
use std::iter;
use std::path;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Mutex;
Expand Down Expand Up @@ -80,7 +78,9 @@ pub fn scan_dir(opts: ScanOptions) -> ScanResult {
// If we have additional content paths, then we have to resolve them as well.
if !opts.content_paths.is_empty() {
let resolved_files: Vec<_> = match fast_glob(&opts.content_paths) {
Ok(matches) => matches.filter_map(|x| path::absolute(x).ok()).collect(),
Ok(matches) => matches
.filter_map(|x| dunce::canonicalize(&x).ok())
.collect(),
Err(err) => {
event!(tracing::Level::ERROR, "Failed to resolve glob: {:?}", err);
vec![]
Expand All @@ -92,27 +92,23 @@ pub fn scan_dir(opts: ScanOptions) -> ScanResult {
let optimized_incoming_globs = get_fast_patterns(&opts.content_paths)
.iter()
.flat_map(|(root, globs)| {
let root = match path::absolute(root) {
Ok(root) => root,
Err(err) => {
event!(
tracing::Level::ERROR,
"Failed to canonicalize base path: {:?}",
err
);

return vec![];
}
};

globs
.iter()
.map(|glob| {
let base = root.clone().display().to_string();
let glob = glob.to_string();
GlobEntry { base, glob }
})
.collect()
globs.iter().filter_map(|glob| {
let root = match dunce::canonicalize(root.clone()) {
Ok(root) => root,
Err(error) => {
event!(
tracing::Level::ERROR,
"Failed to canonicalize base path {:?}",
error
);
return None;
}
};

let base = root.display().to_string();
let glob = glob.to_string();
Some(GlobEntry { base, glob })
})
})
.collect::<Vec<GlobEntry>>();

Expand Down

0 comments on commit caa00b6

Please sign in to comment.