Skip to content

Commit

Permalink
editor: warn on UID duplicates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ogapo committed Jun 10, 2024
1 parent 6cdfbf1 commit 0c39e11
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc

if (fi->uid != 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.
String other_path = ResourceUID::get_singleton()->get_id_path(fi->uid);
if (other_path != path) {
WARN_PRINT_ONCE(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);
Expand Down

0 comments on commit 0c39e11

Please sign in to comment.