From 5122a3e3b00e154c0148bb2709671e6c3a0b0432 Mon Sep 17 00:00:00 2001 From: David Nikdel Date: Mon, 10 Jun 2024 08:34:25 -0400 Subject: [PATCH] editor: warn on UID duplicates This commonly occurs when files are copied outside of the editor and don't get new UIDs. Restricting this warning to first_scan since it's we want to exclude the case of files being moved after initial load which is harder to handle. Addresses https://github.com/godotengine/godot-proposals/discussions/8949 --- editor/editor_file_system.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 3adff84e40b..cdaa001d9e8 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -961,6 +961,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Refuid != ResourceUID::INVALID_ID) { if (ResourceUID::get_singleton()->has_id(fi->uid)) { + // Restrict UID dupe warning to first-scan since we know there are no file moves going on yet. + if (first_scan) { + // Warn if we detect files with duplicate UIDs. + const String other_path = ResourceUID::get_singleton()->get_id_path(fi->uid); + if (other_path != path) { + WARN_PRINT(vformat("UID duplicate detected between %s and %s.", path, other_path)); + } + } ResourceUID::get_singleton()->set_id(fi->uid, path); } else { ResourceUID::get_singleton()->add_id(fi->uid, path);