Skip to content

Commit

Permalink
strip UNC prefix on windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Feb 16, 2023
1 parent 89188d6 commit 600b2fe
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 2 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/next-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ rustls-tls = ["next-core/rustls-tls"]
anyhow = { version = "1.0.47", features = ["backtrace"] }
clap = { version = "4.0.18", features = ["derive", "env"], optional = true }
console-subscriber = { version = "0.1.8", optional = true }
dunce = "1.0.3"
futures = "0.3.25"
mime = "0.3.16"
next-core = { path = "../next-core" }
Expand Down
5 changes: 3 additions & 2 deletions crates/next-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::{

use anyhow::{anyhow, Context, Result};
use devserver_options::DevServerOptions;
use dunce::canonicalize;
use next_core::{
create_app_source, create_page_source, create_web_entry_source, env::load_env,
manifest::DevManifestContentSource, next_config::load_next_config,
Expand Down Expand Up @@ -421,15 +422,15 @@ pub async fn start_server(options: &DevServerOptions) -> Result<()> {
let dir = options
.dir
.as_ref()
.map(|dir| dir.canonicalize())
.map(|dir| canonicalize(dir))
.unwrap_or_else(current_dir)
.context("project directory can't be found")?
.to_str()
.context("project directory contains invalid characters")?
.to_string();

let root_dir = if let Some(root) = options.root.as_ref() {
root.canonicalize()
canonicalize(root)
.context("root directory can't be found")?
.to_str()
.context("root directory contains invalid characters")?
Expand Down
1 change: 1 addition & 0 deletions crates/turbo-tasks-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ auto-hash-map = { path = "../auto-hash-map" }
bitflags = "1.3.2"
bytes = "1.1.0"
concurrent-queue = "1.2.2"
dunce = "1.0.3"
futures = "0.3.25"
futures-retry = "0.6.0"
include_dir = { version = "0.7.2", features = ["nightly"] }
Expand Down
5 changes: 3 additions & 2 deletions crates/turbo-tasks-fs/src/embed/file.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use std::path::PathBuf;

use anyhow::{Context, Result};
use dunce::canonicalize;

use crate::{DiskFileSystemVc, File, FileContentVc, FileSystem};

#[turbo_tasks::function]
pub async fn content_from_relative_path(package_path: &str, path: &str) -> Result<FileContentVc> {
let package_path = PathBuf::from(package_path);
let resolved_path = package_path.join(path);
let resolved_path = std::fs::canonicalize(&resolved_path)
.context("failed to canonicalize embedded file path")?;
let resolved_path =
canonicalize(&resolved_path).context("failed to canonicalize embedded file path")?;
let root_path = resolved_path.parent().unwrap();
let path = resolved_path.file_name().unwrap().to_str().unwrap();

Expand Down
3 changes: 2 additions & 1 deletion crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ impl DiskFileSystem {
}

pub async fn to_sys_path(&self, fs_path: FileSystemPathVc) -> Result<PathBuf> {
let path = Path::new(&self.root);
// just in case there's a windows unc path prefix we remove it with `dunce`
let path = dunce::simplified(Path::new(&self.root));
let fs_path = fs_path.await?;
Ok(if fs_path.path.is_empty() {
path.to_path_buf()
Expand Down

0 comments on commit 600b2fe

Please sign in to comment.