Skip to content

Commit

Permalink
Disallow generate ".uid" files in "res://addons/".
Browse files Browse the repository at this point in the history
  • Loading branch information
Daylily-Zeleen committed Jan 1, 2025
1 parent 2582793 commit d651ace
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,11 +1261,13 @@ 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.
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
fi->uid = ResourceUID::get_singleton()->create_id();
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid));
if (!path.begins_with("res://addons/")) {
// Create a UID.
Ref<FileAccess> f = FileAccess::open(path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
fi->uid = ResourceUID::get_singleton()->create_id();
f->store_line(ResourceUID::get_singleton()->id_to_text(fi->uid));
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,10 +1451,12 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String

void EditorNode::ensure_uid_file(const String &p_new_resource_path) {
if (ResourceLoader::exists(p_new_resource_path) && !ResourceLoader::has_custom_uid_support(p_new_resource_path) && !FileAccess::exists(p_new_resource_path + ".uid")) {
Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();
f->store_line(ResourceUID::get_singleton()->id_to_text(id));
if (!p_new_resource_path.begins_with("res://addons/")) {
Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE);
if (f.is_valid()) {
const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();
f->store_line(ResourceUID::get_singleton()->id_to_text(id));
}
}
}
}
Expand Down

0 comments on commit d651ace

Please sign in to comment.