diff --git a/Cargo.lock b/Cargo.lock index 49a0f06a3..02233b712 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3479,6 +3479,7 @@ dependencies = [ "dioxus-rsx-hotreload", "dioxus-rsx-rosetta", "dirs", + "dunce", "env_logger 0.11.5", "escargot", "flate2", @@ -7767,6 +7768,7 @@ dependencies = [ name = "manganis-macro" version = "0.6.1" dependencies = [ + "dunce", "manganis", "manganis-core", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 90785ceda..980e9c585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -230,7 +230,7 @@ wry = { version = "0.45.0", default-features = false } tao = { version = "0.30.8", features = ["rwh_05"] } webbrowser = "1.0.1" infer = "0.16.0" -dunce = "1.0.2" +dunce = "1.0.5" urlencoding = "2.1.2" global-hotkey = "0.6.0" rfd = { version = "0.14", default-features = false } diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 1f523fcd3..bcd4ed233 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -61,6 +61,7 @@ syn = { workspace = true, features = ["full", "extra-traits", "visit", "visit-mu headers = "0.4.0" walkdir = "2" +dunce = { workspace = true } # tools download dirs = { workspace = true } diff --git a/packages/cli/src/build/bundle.rs b/packages/cli/src/build/bundle.rs index 0fb6c0190..a25e7569e 100644 --- a/packages/cli/src/build/bundle.rs +++ b/packages/cli/src/build/bundle.rs @@ -10,6 +10,7 @@ use std::collections::HashSet; use std::future::Future; use std::path::{Path, PathBuf}; use std::pin::Pin; +use std::sync::atomic::Ordering; use std::{sync::atomic::AtomicUsize, time::Duration}; use tokio::process::Command; @@ -394,7 +395,8 @@ impl AppBundle { ) -> Pin> + Send + 'a>> { Box::pin(async move { // If this asset is in the manifest, we don't need to remove it - if bundled_output_paths.contains(path.canonicalize()?.as_path()) { + let canon_path = dunce::canonicalize(path)?; + if bundled_output_paths.contains(canon_path.as_path()) { return Ok(()); } // Otherwise, if it is a directory, we need to walk it and remove child files @@ -438,7 +440,8 @@ impl AppBundle { } let asset_count = assets_to_transfer.len(); - let current_asset = AtomicUsize::new(0); + let started_processing = AtomicUsize::new(0); + let copied = AtomicUsize::new(0); // Parallel Copy over the assets and keep track of progress with an atomic counter let progress = self.build.progress.clone(); @@ -447,19 +450,18 @@ impl AppBundle { assets_to_transfer .par_iter() .try_for_each(|(from, to, options)| { - let current = current_asset.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - - tracing::trace!("Starting asset copy {current}/{asset_count} from {from:?}"); + let processing = started_processing.fetch_add(1, Ordering::SeqCst); + tracing::trace!("Starting asset copy {processing}/{asset_count} from {from:?}"); let res = process_file_to(options, from, to); - if let Err(err) = res.as_ref() { tracing::error!("Failed to copy asset {from:?}: {err}"); } + let finished = copied.fetch_add(1, Ordering::SeqCst); BuildRequest::status_copied_asset( &progress, - current, + finished, asset_count, from.to_path_buf(), ); diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs index f8390a1be..40b2cdba9 100644 --- a/packages/cli/src/serve/handle.rs +++ b/packages/cli/src/serve/handle.rs @@ -2,7 +2,6 @@ use crate::{AppBundle, Platform, Result}; use anyhow::Context; use dioxus_cli_opt::process_file_to; use std::{ - fs, net::SocketAddr, path::{Path, PathBuf}, process::Stdio, @@ -190,7 +189,7 @@ impl AppHandle { } // Canonicalize the path as Windows may use long-form paths "\\\\?\\C:\\". - let changed_file = fs::canonicalize(changed_file) + let changed_file = dunce::canonicalize(changed_file) .inspect_err(|e| tracing::debug!("Failed to canonicalize hotreloaded asset: {e}")) .ok()?; diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index 1816b7174..a7272b6c7 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -45,7 +45,7 @@ tokio = { workspace = true, features = [ ], optional = true } webbrowser = "0.8.0" infer = "0.11.0" -dunce = "1.0.2" +dunce = { workspace = true } slab = { workspace = true } rustc-hash = { workspace = true } dioxus-hooks = { workspace = true } diff --git a/packages/manganis/manganis-macro/Cargo.toml b/packages/manganis/manganis-macro/Cargo.toml index b83472bc6..8e41cd2b9 100644 --- a/packages/manganis/manganis-macro/Cargo.toml +++ b/packages/manganis/manganis-macro/Cargo.toml @@ -19,6 +19,7 @@ proc-macro2 = { workspace = true } quote = { workspace = true } syn = { workspace = true, features = ["full", "extra-traits"] } manganis-core = { workspace = true } +dunce = { workspace = true } [features] default = [] diff --git a/packages/manganis/manganis-macro/src/asset.rs b/packages/manganis/manganis-macro/src/asset.rs index 5774c37d4..315ab58cb 100644 --- a/packages/manganis/manganis-macro/src/asset.rs +++ b/packages/manganis/manganis-macro/src/asset.rs @@ -17,11 +17,12 @@ fn resolve_path(raw: &str) -> Result { // /users/dioxus/dev/app/ // is the root of // /users/dioxus/dev/app/assets/blah.css - let manifest_dir = std::env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .unwrap() - .canonicalize() - .unwrap(); + let manifest_dir = dunce::canonicalize( + std::env::var("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .unwrap(), + ) + .unwrap(); // 1. the input file should be a pathbuf let input = PathBuf::from(raw); @@ -34,7 +35,7 @@ fn resolve_path(raw: &str) -> Result { }; // 3. Ensure the path exists - let Ok(path) = path.canonicalize() else { + let Ok(path) = dunce::canonicalize(path) else { return Err(AssetParseError::AssetDoesntExist { path: input.clone(), });