Fix: Asset Cache On Windows & Asset Status (#3525)

* fix: asset caching on windows
* fix: asset status
This commit is contained in:
Miles Murgaw authored and GitHub committed 2025-01-08 15:08:18 -08:00
1 parent 5ea0867a34
commit a3812d66da
8 files changed
+23 -17

No files matched your search

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