do not change resource uuid when moving it in the editor

This commit is contained in:
Dmitry Stepanov
2025-07-05 18:01:22 +03:00
parent c2352503d9
commit 886e22307d
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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) => {
+5
View File
@@ -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.