Fix: Windows Manganis Asset Hot Reload (#3330)

* fix: windows asset hot reload

* revision: canonicalize err handling
This commit is contained in:
Miles Murgaw authored and GitHub committed 2024-12-10 16:24:39 -08:00
1 parent 38cb2759e8
commit b20c8ac277
1 file changed
+7 -1
+7 -1
View File
@@ -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 {