From b20c8ac27763fd00600f47c0ed852cac111e7463 Mon Sep 17 00:00:00 2001 From: Miles Murgaw Date: Tue, 10 Dec 2024 19:24:39 -0500 Subject: [PATCH] Fix: Windows Manganis Asset Hot Reload (#3330) * fix: windows asset hot reload * revision: canonicalize err handling --- packages/cli/src/serve/handle.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs index 4021cb2c85..f5968f3ae2 100644 --- a/packages/cli/src/serve/handle.rs +++ b/packages/cli/src/serve/handle.rs @@ -1,6 +1,7 @@ use crate::{AppBundle, Platform, Result}; use anyhow::Context; use std::{ + fs, net::SocketAddr, path::{Path, PathBuf}, process::Stdio, @@ -187,8 +188,13 @@ impl AppHandle { } } + // Canonicalize the path as Windows may use long-form paths "\\\\?\\C:\\". + let changed_file = fs::canonicalize(changed_file) + .inspect_err(|e| tracing::debug!("Failed to canonicalize hotreloaded asset: {e}")) + .ok()?; + // The asset might've been renamed thanks to the manifest, let's attempt to reload that too - if let Some(resource) = self.app.app.assets.assets.get(changed_file).as_ref() { + if let Some(resource) = self.app.app.assets.assets.get(&changed_file).as_ref() { let res = std::fs::copy(changed_file, asset_dir.join(resource.bundled_path())); bundled_name = Some(PathBuf::from(resource.bundled_path())); if let Err(e) = res {