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

Update script documentation removed files on startup #95965

Conversation

Hilderin
Copy link
Contributor

This PR is a prerequisite for #95821

It will adds the removed files in update_script_paths_documentation on first scan by comparing the file cache with the files on disk. It's important for #95821 so the removed scripts could be removed from the documentation.

Currently, update_script_paths_documentation does not remove documentation if the file does not exists on disk it will be implemented in #95821.

I tested with a project that has 3000 scripts files. After removing the files while the editor is closed and starting it, the method EditorFileSystem::_process_removed_files_first_scan tooks 22ms to find the 3000 missing scripts.

This is a team work with @anvilfolk

@Hilderin Hilderin changed the title Update script document removed files on startup Update script documentation removed files on startup Aug 22, 2024
@Hilderin Hilderin force-pushed the update-script-documentation-file-remove-on-startup branch from 366b66b to 2bf8a42 Compare August 22, 2024 23:25
@Calinou Calinou added this to the 4.x milestone Aug 22, 2024
@AThousandShips AThousandShips requested a review from a team August 23, 2024 08:35
Copy link
Contributor

@anvilfolk anvilfolk left a comment

Choose a reason for hiding this comment

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

The code makes sense to me. I'd like to see an added comment but it isn't critical! :)

Thanks for putting this together so fast!

@Hilderin Hilderin force-pushed the update-script-documentation-file-remove-on-startup branch from 2bf8a42 to 3698124 Compare August 23, 2024 16:17
@anvilfolk
Copy link
Contributor

anvilfolk commented Aug 23, 2024

Actually, I just noticed there's a function called EditorFileSystem::update_files() which may be used for this purpose. It already does something very similar to what we need:

if (!FileAccess::exists(file)) {
	//was removed
	_delete_internal_files(file);
	if (cpos != -1) { // Might've never been part of the editor file system (*.* files deleted in Open dialog).
		...
		if (ClassDB::is_parent_class(fs->files[cpos]->type, SNAME("Script"))) {
			_queue_update_script_class(file, fs->files[cpos]->type, "", "", ""); ///////////// This here might regen docs?
			if (!fs->files[cpos]->script_class_icon_path.is_empty()) {
				update_files_icon_cache = true;
			}
		}

Perhaps it is worth collecting all the script files in a Vector and call this function instead. Would that work?

@Hilderin
Copy link
Contributor Author

This method skip files that are not in the FileSystem because of the if (!_find_file(file, &fs, cpos)) {.
Also, the problem calling that method directly is that we try to avoid processing files while scanning. That's why I queued the documentation to be updated in update_script_paths_documentation which is processed after the scan. In the PR #93064, that should be merge soon, I added a progress bar to give feedback to the user while updating the documentation.

@anvilfolk
Copy link
Contributor

You know best! I just noticed the method and thought it might be relevant! Exciting about the progress bar too! :)

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Sep 3, 2024
@Hilderin Hilderin force-pushed the update-script-documentation-file-remove-on-startup branch from 3698124 to 1c3bc2f Compare September 4, 2024 10:12
@akien-mga akien-mga merged commit 8d120a5 into godotengine:master Sep 4, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants