Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-create missing .uid files #100787

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Re-create missing .uid files
  • Loading branch information
KoBeWi committed Dec 24, 2024
commit e0ca8be392234cf604d23d42876e2c987602ed4b
10 changes: 7 additions & 3 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,11 +1260,15 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir,
}
}

if (fi->uid == ResourceUID::INVALID_ID && ResourceLoader::exists(path) && !ResourceLoader::has_custom_uid_support(path) && !FileAccess::exists(path + ".uid")) {
// Create a UID.
if (ResourceLoader::exists(path) && !ResourceLoader::has_custom_uid_support(path) && !FileAccess::exists(path + ".uid")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both ResourceLoader methods go through all loaders and check if the file is recognized. I think this can be improved.

// Create a UID file and new UID, if it's invalid.
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
fi->uid = ResourceUID::get_singleton()->create_id();
if (fi->uid == ResourceUID::INVALID_ID) {
fi->uid = ResourceUID::get_singleton()->create_id();
} else {
WARN_PRINT(vformat("Missing .uid file for path \"%s\". The file was re-created from cache.", path));
}
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid));
}
}
Expand Down