1
0
Эх сурвалжийг харах

Fix: Windows Manganis Asset Hot Reload (#3330)

* fix: windows asset hot reload

* revision: canonicalize err handling
Miles Murgaw 6 сар өмнө
parent
commit
b20c8ac277

+ 7 - 1
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 {