diff --git a/fyrox-resource/src/manager.rs b/fyrox-resource/src/manager.rs index 96392210b..69bfedd86 100644 --- a/fyrox-resource/src/manager.rs +++ b/fyrox-resource/src/manager.rs @@ -650,7 +650,7 @@ impl ResourceManagerState { } } } - notify::EventKind::Create(_) => { + notify::EventKind::Create(_) if !registry.is_registered(&relative_path) => { let uuid = Uuid::new_v4(); match registry.modify().write_metadata(uuid, &relative_path) { Ok(old_path) => { diff --git a/fyrox-resource/src/registry.rs b/fyrox-resource/src/registry.rs index 709854112..2fa9a4b85 100644 --- a/fyrox-resource/src/registry.rs +++ b/fyrox-resource/src/registry.rs @@ -426,6 +426,11 @@ impl ResourceRegistry { .find_map(|(k, v)| if v == path { Some(*k) } else { None }) } + /// Checks if the path is registered in the resource registry. + pub fn is_registered(&self, path: &Path) -> bool { + self.path_to_uuid(path).is_some() + } + /// Searches for supported resources starting from the given path and builds a mapping `UUID -> Path`. /// If a supported resource does not have a metadata file besides it, this method will automatically /// add it with a new UUID and add the resource to the registry.