Fix: race condition in asset resolution
This commit is contained in:
3 files changed
+21
-11
No files matched your search
Generated
+3
@@ -3371,6 +3371,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "dioxus-core-types"
|
||||
version = "0.6.0-alpha.3"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dioxus-desktop"
|
||||
|
||||
@@ -11,3 +11,4 @@ keywords = ["dom", "ui", "gui", "react", ]
|
||||
|
||||
|
||||
[dependencies]
|
||||
once_cell.workspace = true
|
||||
@@ -1,16 +1,22 @@
|
||||
static mut BUNDLED: bool = false;
|
||||
static mut CHECKED_YET: bool = false;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub fn is_bundled_app() -> bool {
|
||||
// unsafe to implement a dumb cell without pulling in deps / mutexes
|
||||
// we're okay with a race condition here since the bundled flag is always set to the same value
|
||||
unsafe {
|
||||
if !CHECKED_YET {
|
||||
CHECKED_YET = true;
|
||||
BUNDLED = std::env::var("DIOXUS_CLI_ENABLED").is_ok()
|
||||
|| !matches!(std::env::var("CARGO_MANIFEST_DIR"), Ok(path) if !path.is_empty());
|
||||
static BUNDLED: Lazy<bool> = Lazy::new(|| {
|
||||
// If the env var is set, we're bundled
|
||||
if std::env::var("DIOXUS_CLI_ENABLED").is_ok() {
|
||||
return true;
|
||||
}
|
||||
|
||||
BUNDLED
|
||||
}
|
||||
// If the cargo manifest dir is set, we're not bundled.
|
||||
// Generally this is only set with `cargo run`
|
||||
if let Ok(path) = std::env::var("CARGO_MANIFEST_DIR") {
|
||||
if !path.is_empty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
});
|
||||
|
||||
*BUNDLED
|
||||
}
|
||||
Reference in new issue
Block a user